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 Dove with the following information:
Dove
Where:
-origin: String
Dove() - default constructor.
-age:int
Dove(origin: String, age:int) constructor, which sets values to origin and age.
+Dove()
+Dove(origin: String, age:int)
getOrigin():String returns a string s, which is obtained by concatenating the age before the original string.
+getOrigin():String
+getAge():int
+setAge(age:int):void
getAge():int-return age.
setAge(age:int):void - update age=new age / 2.
Do not format the result.
The program output might look something like:
Enter origin: dove
Enter age: 1
Enter origin: dove
1. Test getOrigin()
Enter age: 1
1. Test getOrigin()
2. Test setAge()
2. Test setAge()
Enter TC (1 or 2): 1
Enter TC (1 or 2): 2
Zoom
+ 100%
Close