1 of 1
Paper No: 8
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 Tofu with the following information:
Tofu
Where:
-maker:String-quantity:int
Tofu() - default constructor.
+Tofu()
+Tofu(maker:String, quantity:int)
Tofu(maker:String, quantity:int) constructor, which sets values to maker and quantity.
+getMaker():String
getMaker():String returns a string s, which is obtained by lowercase the first and last letters of the maker string.
+getQuantity():int
+setQuantity(quantity:int):void
getQuantity():int - return quantity.
setQuantity(quantity:int):void quantity=new quantity.
Do not format the result.
update
The program output might look something like:
Enter maker: TofU
Enter maker: tofu
Enter quantity: 2
Enter quantity: 2
1. Test getMaker()
1. Test getMaker()
2. Test setQuantity()
2. Test setQuantity()
Zoom
Close
+ 100%