• Solutions will be marked by Automated Marking Software.
The use of tools other than those allowed in the above section whether intentionally or
unintentionally, is considered a violation of the exam rules, and the exam result will be 0.• Do not change the names of the folders and files specified (or required) in the exam. If you change it (incorrectly), the marking software can not find the execute file (.jar) to mark, thus the exam result will be 0.
All source code files .java in the projects will be created in the default package of the NetBean
(2 marks)
Do not pay attention to the real meaning of objects, variables, and their values in the questions below.
Write a class Ostrich (in the default package of the NetBeans) with the following information:
Ostrich Where:
2 of 3 Paper No: 1
-name: String -weight:int
-step: int +Ostrich ()
+Ostrich (name: String, weight:int)
+getName():StringgetStep():int+
+getWeight ():int
+setWeight (weight:int):void+toString(): String
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 +5toString(): String return a string format that
+ 100%
Close
information of the Antrinh.
Zoom
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.