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