PRO192_-_PE_-_SU_2024_-_Block_5_2614.webp
K

PRO192_-_PE_-_SU_2024_-_Block_5_2614.webp

Question 1:
(2 marks) Read PE instructions at the bottom of the exam paper.
Do not pay attention to real meaning of objects, variables and their values in the questions below.
Write a class named Crown with the following information:
Crown
-color:String
Where:
Crown() - default constructor.
-weight:int
Crown(color:String, weight:int) constructor, which sets values to color and weight.
+Crown()
+Crown(color:String, weight:int)
getColor():String - returns an s string, by writing the first letter that appears in the color string lowercase.
+getColor():String+getWeight():int
getWeight():int - return weight.
+setWeight(weight:int):void
setWeight(weight:int):void weight+old weight.update weight=new
The program output might look something like:
Do not format the result.
Enter color: RED
Enter color: red
Enter weight: 2
Enter weight: 2
1. Test getColor()
1. Test getColor()
2. Test setWeight()
2. Test setWeight()
Enter TC (1 or 2): 1
Enter TC (1 or 2): 2
OUTPUT:
rED
Enter new weight: 5
OUTPUT:7
Zoom FUD
Question 2:
+ 100%
Close
Chưa có bình luận nào.

Thông tin

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

Image metadata

Filename
PRO192_-_PE_-_SU_2024_-_Block_5_2614.webp
File size
86.4 KB
Dimensions
1920px x 859px

Share this media

Back
Bên trên Bottom