Troubleshooting:
If the given project (e.g. Q1) runs with error, you need to run "Clean and Build Project" (Shift+F11). If still error, try to rename or copy the project to other one, e.g. from Q1 to Q1X or Q1Y.
Do not pay attention to real meaning of objects, variables and their values in the questions below.
Question 1: (5 marks)
In this question you should complete some methods in MyList.java file.
The class Phone with 3 data members: id, weight and price is given and you do not need to edit it. In this class, id must be unique (there is no duplicated id in the list), weight>0, and price>0. The MyList class is a linked list of Phone objects. The following methods should be completed:
void addLast(String xld, int xWeight, int xPrice).
void f1() - Do not edit this method. Your task is to complete the addLast(...) method above only.The expected output in the file f1.txt should be the following:
H,6,7) (C,4,5) (1,5,8)(
1
void f2() -There is a given Phone objects (named v) in this function. Suppose the list contains at least 3 elements. Write statements to insert v to the list such that v will be the 3rd node after insertion. The expected output in the file f2.txt should be the following:
(D,4,7) (E,9,2) (Q,7,6)
(D,4,7) (E,9,2) (New,8,9) (Q,7,6)
Close
+ 100%
Zoom