CSD201_-_PE_-_SP_2024_-_s_-_10_1506.webp
T

CSD201_-_PE_-_SP_2024_-_s_-_10_1506.webp

In this question you should complete some methods in MyList.java file.
void addLast(String xMaker, int xVolume, int xColor) - check if xMaker.charAt(0) == 'A' then do nothing, otherwise add new node with maker=xMaker, volume=xVolume, color=xColor to the end
of the list. (volume and color 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 Bottle objects x, y, z in this function. Suppose the list contains at least 3 elements. Write statements to insert x, y and z to the list so that x, y, z will be at positions 1, 2 and 4 (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) (1,3,7)
(C,9,8) (Χ,1,2) (Υ,2,3) (D,6,3) (2,3,4) (E,8,5) (F,5,4) (1,4,9) (1,3,7)
1
void f3() - Suppose the list contains at least 3 elements. Remove the first node having maximum color and insert it at position 1. (The head's position is 0). 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)
(C,7,6) (F,7,9) (D,6,7) (E,3,8) (G,8,7) (H,4,9) (1,8,3)
void f4() - Suppose the list contains at least 6 elements and p is the 6th element in the list. Change
the color of p to 88, then sort all elements before p ascendingly by color. The content of the
output file f4.txt must be the following:
(C,9,8) (D,11,12) (E,8,7) (F,1,2) (1,7,9) (J,6,8) (K,5,6) (L,9,8) (M,3,4)
(F,1,2) (E,8,7) (C,9,8) (1,7,9) (D,11,12) (J,6,88) (K,5,6) (L,9,8) (M,3,4)
Zoom
Close

Question 2: (4 marks)
+ 100%
Chưa có bình luận nào.

Thông tin

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

Image metadata

Filename
CSD201_-_PE_-_SP_2024_-_s_-_10_1506.webp
File size
268.1 KB
Dimensions
947px x 898px

Share this media

Back
Bên trên Bottom