CSD201_-_FA_2024_-_Block_5_-_PE_3214.webp
Lisanna_chan

CSD201_-_FA_2024_-_Block_5_-_PE_3214.webp

If the given project (e.g. Q1) runs with error, you need to run "Clean and Build Project" (Shierror, try to rename or copy the project to other one, e.g. from Q1 to Q1X or Q1Y,...
Do not pay attention to real meaning of objects, variables and their values in the questions t Quesion 1: (4 marks)
In this question you should complete some methods in MyList.java file.
The class Pen with 3 data members: owner, price and color is given and you do not need MyList class is a linked list of Pen objects. The following methods should be completed:
void addLast(String xOwner, int xPrice, int xColor) - check if xOwner.charAt(0) = nothing, otherwise add new node with owner=xOwner, price=xPrice, color=xColor the list. (price and color can get arbitrary, even negative values).
void f1() - Do not edit this method. Your task is to complete the addLast(...) methc Output in the file f1.txt must be the following:
(B,5,3) (C,6,5) (D,2,4) (E,7,9) (F,4,7)
void f2()-There are 2 given Pen objects x, y in this function. Suppose the list cont elements. Write statements to insert x and y to the list so that y will be the 1st (hthe 2nd element in the list. Output in the file f2.txt must be the following:(C,9,8) (D,6,3) (E,8,5) (F,5,4) (1,4,9)
(Y,3,4) (Χ,1,2) (C,9,8) (D,6,3) (E,8,5) (F,5,4) (1,4,9)
100%
Zoom
Close

Chưa có bình luận nào.

Thông tin

Category
CSD201
Thêm bởi
Lisanna_chan
Ngày thêm
Lượt xem
4,900
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
CSD201_-_FA_2024_-_Block_5_-_PE_3214.webp
File size
224.7 KB
Dimensions
765px x 852px

Share this media

Back
Bên trên Bottom