PRO192_-_PE_-_SP_2024_1494.webp
O

PRO192_-_PE_-_SP_2024_1494.webp

  • Media owner Obanai89
  • Ngày thêm
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 Zebra with the following information:
Zebra
Where:
Zebra() - default constructor.
-owner:String
-weight:int
Zebra(owner:String, weight:int) constructor, which sets values to owner and weight.
+Zebra()
+Zebra(owner:String, weight:int)
+getOwner():String
getOwner():String returns a string s, which is obtained by removing the even number characters of
+getWeight():int
owner string.
+setWeight(weight:int):void
getWeight():int - return weight.
setWeight(weight:int):void weight-length of the owner.update weight=new
Do not format the result.
The program output might look something like:
Enter owner: zebra123
Enter owner: zebra123
Enter weight: 200
Enter weight: 200
1. Test getOwner()
1. Test getOwner()
2. Test setWeight()
2. Test setWeight()
Enter TC (1 or 2): 1
Enter TC (1 or 2): 2
OUTPUT:
zebra13
Enter new weight: 100
OUTPUT:92
Zoom

+ 95%
Close

Chưa có bình luận nào.

Thông tin

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

Image metadata

Filename
PRO192_-_PE_-_SP_2024_1494.webp
File size
208.4 KB
Dimensions
1920px x 990px

Share this media

Back
Bên trên Bottom