void addLast(String xOwner, int xPrice, int xColor) - check if xOwner.charAt(0) == 'A' then do nothing, otherwise add new node with owner=xOwner, price=xPrice, color=xColor to the end of 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(...) 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)
void f2() -There are 2 given Pen 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 y will be the 1st (head), x will be the 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) (X,1,2) (C,9,8) (D,6,3) (E,8,5) (F,5,4) (1,4,9)
1
void f3()-Suppose the list is not empty. Remove the first node having color<6. Output in the file f3.txt must be the following:
(C,8,6) (D,6,7) (E,9,2) (F,5,8) (G,9,7) (H,6,8) (1,7,3)
(C,8,6) (D,6,7) (F,5,8) (G,9,7) (H,6,8) (1,7,3)
void f4() - Suppose the list contains at least 5 elements. Sort the first 5 elements ascendingly by color. The content of the output file f4.txt must be the following:
(C,7,9) (D,16,7) (E,6,16) (F,5,6) (1,4,5) (J,3,4) (K,2,3)(1,4,5) (F,5,6) (D,16,7) (C,7,9) (E,6,16) (J,3,4) (K,2,3)
+ 90%
Zoom
Close