CSD201_-_PE_-_01_-_SU_2022_-_Trial_2847.webp
ThaiNgoc2003

CSD201_-_PE_-_01_-_SU_2022_-_Trial_2847.webp

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 Car with 2 data members: owner and price is given and you do not need to edit it. The MyList class is a linked list of Car objects. The following methods should be completed:
void addLast(String xOwner, int xPrice) - check if xOwner.charAt(0) = 'A' or xPrice>100 then do nothing, otherwise add new car with owner=xOwner, price=xPrice, price=xPrice to the end of the list. (price can get arbitrary value, even negative).
void f1() - This method is used to test the addLast methode above. You do not need to edit this function. Output in the file f1.txt must be the following:(B,3) (C,7) (D,2) (E,6) (F,4)
void f2() - There are given objects x and y. You should write statements so that y will be the first element of the list. Output in the file f2.txt must be the following:(C,9) (D,6) (E,8) (F,2) (1,6)
Zoom
+ 100%
Close
Chưa có bình luận nào.

Thông tin

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

Image metadata

Filename
CSD201_-_PE_-_01_-_SU_2022_-_Trial_2847.webp
File size
206.5 KB
Dimensions
1145px x 753px

Share this media

Back
Bên trên Bottom