PRO192_-_PE01_-_FA_2024_2886.webp
H

PRO192_-_PE01_-_FA_2024_2886.webp

Zoom
-name: String -weight:int
-step: int
+Ostrich ()
+Ostrich (name: String, weight:int)
+getName():String
+getStep():int+getWeight ():int
+setWeight (weight:int):void
+toString(): String
Ostrich ()- default constructor.
Ostrich (name: String, weight: int)- parameterized constructor, which sets values to name and weight. If weight is less than or equal to 0, set it to 1. The step is calculated by the following formula:
If 1<=weight <=10 then step = 5 If weight >10 then step = weight +5
getName(): String-return the name in lowercase format.
getStep():int - return the step
getWeight (): int -return the weight.
setWeight(weight: int): void-update the weight. If the weight is less than or equal to 0, set it to 1 and
the step is set by the following formula:If 1<=weight <=10 then step = 5
If weight >10 then step = weight +5
toString(): String return a string format that contains all the information of the Ostrich:name, weight, step. The name in lowercase format.
Do not format the result.
The program output might look something like this:
Enter name: Aves
Enter weight: 10
Enter name: Aves
Enter weight: 10
1. Test getName()
2. Test set Weight()
1. Test getName()
2. Test set Weight()
3. Test toString()
3. Test toString()
Enter TC (1, 2 or 3): 1
Enter TC (1, 2 or 3): 2
Enter new weight: 0
OUTPUT:
aves
OUTPUT:5
Enter name: Aves
Enter weight: 20
1. Test getName()
2. Test set Weight()
3. Test toString()
Enter TC (1, 2 or 3): 2
Enter new weight: 25
OUTPUT:30
Enter name: Aves
Enter weight: 25
1. Test getName()
2. Test set Weight()
3. Test toString()
Enter TC (1, 2 or 3): 3
OUTPUT:
aves, 25,30

+ 100%
Close
Chưa có bình luận nào.

Thông tin

Category
PRO192
Thêm bởi
Hương Mai
Ngày thêm
Lượt xem
5,428
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
PRO192_-_PE01_-_FA_2024_2886.webp
File size
284 KB
Dimensions
1920px x 1009px

Share this media

Back
Bên trên Bottom