4. Submission: to submit the project Q1, at first you must select Question No = 1, browse and select the project folder (e.g. 1, Q1 or Q1X,...) then click the Submit button. Do the same for other questions.Do not submit the un-edited given project. If project is too big for submission, delete all f1.txt, f2.txt,....
5. Do not use accented Vietnamese when writing comments in programs.
6. Do not add new import statement(s) to given files.
7. Software tools must be used: NetBeans IDE 8.x and Java JDK 1.8.
If at least one of the above requirements is not followed, the exam will get ZERO.
Trouble shooting:
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: (4 marks)
In this question you should complete some methods in MyList.java file.
The class Cala with 3 data members: owner, horn and color is given and you do not need to edit it. The MyList class is a linked list of Cala objects. The following methods should be completed:
void addLast(String xOwner, int xHorn, int xColor) - check if xOwner.charAt(0) == 'A' then do nothing, otherwise add new node with owner=xOwner, horn=xHorn, color=xColor to the end of the list. (horn 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 Cala 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, 4
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) (1,3,7)
+ 100%
Zoom
Close