CSD201_-_PE_-_SP_2025_-_Block_5_3859.webp
Lucy_boy1

CSD201_-_PE_-_SP_2025_-_Block_5_3859.webp

Question 1:(4 marks)
☑Kizspy. me In this question you should complete some methods in MyList.java file.
The class Box with 3 data members: place, depth and type is given and you do not need to edit it. The
MyList class is a linked list of Box objects. The following methods should be completed:


void addLast(String xPlace, int xDepth, int xType) - check if xPlace.charAt(0) == 'B' then do nothing,
otherwise add new node with place-xPlace, depth=xDepth, type-xType to the end of the list.
(depth and type can get arbitrary, even negative values).
void f1()- Do not edit this method. Your task is to complete the addLast(...) method above only.
Output in the file f1.txt must be the following:
(A,9,8) (C,6,5) (D,2,4) (E,7,9) (F,4,7)
.
void f2()-There are 2 given Box objects x, y in this function. Suppose the list contains at least 3
elements. Write statements to insert x and y to the list so that x will be the 1st (head), y will be
the 4th 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)
(X,1,2) (C,9,8) (D,6,3) (Y,3,4) (E,8,5) (F,5,4) (1,4,9)
Zoom
+ 100%
1
Close
Chưa có bình luận nào.

Thông tin

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

Share this media

Back
Bên trên Bottom