CSD201_-_PE_-_SU_2025_-_Block_1_3995.webp
G

CSD201_-_PE_-_SU_2025_-_Block_1_3995.webp

✓ Kizspy.me
m this question you should complete some methious in MyList.java me.
Do not pay attention to real meaning of objects, variables and their values in the questions below.
Question 1: (4 marks)
In this question you should complete some methods in MyList.java file.
The class Canary with 3 data members: place, song and wing is given and you do not need to edit it. The
MyList class is a linked list of Canary objects. The following methods should be completed:

void addLast(String xPlace, int xSong, int xWing) - check if xPlace.charAt(0) == 'A' then do nothing,
otherwise add new node with place-xPlace, song-xSong, wing-xWing to the end of the list. (song
and wing 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:
(B,5,3) (C,6,5) (D,2,4) (E,7,9) (F,4,-7) (G,-3,2)

void f2()-There are 3 given Canary objects x, y, z in this function. Write statements to insert x,
y and z to the list so that x, y, z will be at positions 2, 5 and 6 (The head's position is 0). 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) (J,3,7)
(C,9,8) (D,6,3) (X,1,2) (E,8,5) (F,5,4) (Y,2,3) (Z,3,4) (1,4,9) (J,3,7)
1

void f3() -Suppose p is the first node having place-E, and p.info.wing-k. Remove all elements
having wing<k. Output in the file f3.txt must be the following:
(C,7,6) (D,6,7) (E,3,8) (F,7,9) (G,8,7) (H,4,9) (1,8,3) (J,5,4)
(E,3,8) (F,7,9) (H,4,9)
Zoom
+ 102%
Close
Chưa có bình luận nào.

Thông tin

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

Share this media

Back
Bên trên Bottom