1, 2000, 500, 2500
Question 3:
(2 marks)
Write a class named Product with the following information:
Product
Where:
id: int
Product()-default constructor
- name:String
- price: double
5 of 6
Paper No: 1
+ Product()
Product(id:int, name:String, price:double)
+ Product(id:int, name:String,price:double)
- parameterized constructor: set values to
the id, name, and price
+ getId():int + setName(name: String): void + getName():String
getId():int-return the id
+ setPrice(price: double): void
setName(name: String): void set the name to the name property
+ getPrice():double
+ toString(): String
getName():String return the name in
Zoom
Close
+ 100%