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