PE_CSD_SP22_Demo_264.webp
kidhood

PE_CSD_SP22_Demo_264.webp

  • Media owner kidhood
  • Ngày thêm
Bài viết gốc: Chủ đề 'PE CSD SP22 Demo'
Question paper (build 07.05.20.19)
X
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 Bird with 3 data members: type, rate and wing is given and you do not need to edit it. The MyList class is a linked list of Bird objects. The following methods should be completed:
void addLast(String xType, int xRate, int xWing) - check if xType.charAt(0) == 'B' then do nothing,otherwise add new node with type=xType, rate=xRate, wing=xWing to the end of the list. (rateand wing 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) (Ε,7,9) (F,4,-7) (G,-3,2)
void f2() -There are 2 given Bird 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 4th, y will be the 6th node. Output in the file f2.txt must be the following:(C,9,8) (D,6,3) (Ε,8,5) (F,5,4) (1,4,9)
1
(C,9,8) (D,6,3) (Ε,8,5) (Χ,1,2) (F,5,4) (1,3,4) (1,4,9)
void f3()-Find the second node having rate<6 then change its' wing to 99. 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) (F,5,99) (G,9,7) (H,6,8) (1,7,3)
100%
Zoom
Close
Chưa có bình luận nào.

Thông tin

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

Image metadata

Filename
PE_CSD_SP22_Demo_264.webp
File size
105 KB
Dimensions
1908px x 1019px

Share this media

Back
Bên trên Bottom