void addLast(String xOwner, int xColor, int xSize) check if xOwner.charAt(0) == 'B' then do nothing, otherwise add new node with owner=xOwner, color=xColor, size=xSize to the end of the list. (color and size 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 Boat objects x, y in this function. Suppose the list contains at least 5 elements. Write statements to insert x and y to the list so that x will be the first (head), y will be the third 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) (1,3,4) (D,6,3) (E,8,5) (F,5,4) (1,4,9)
1
void f3()- Suppose the list contains at least 4 elements. Remove the second node having color < 6 (thus if only one node having color < 6 then do nothing). Output in the file f3.txt must be the following:(C,8,6) (D,3,5) (E,9,2) (F,5,8) (G,9,7) (H,6,8) (1,7,3)(C,8,6) (D,3,5) (E,9,2) (G,9,7) (H,6,8) (1,7,3)
void f4() - Suppose the list contains at least 4 elements. Sort the last 4 elements ascendingly by color. The content of the output file f4.txt must be the following:(C,7,9) (D,6,7) (E,5,6) (F,4,5) (1,10,4) (J,3,11) (K,2,3)(C,7,9) (D,6,7) (E,5,6) (K,2,3) (J,3,11) (F,4,5) (1,10,4)
+ 85%
Zoom
Close