+ setName(name: String): void
+ getName():String
+ setPrice(price: double): void
+ getPrice():double
+ toString(): String
setName(name: String): void set the
name to the name property
getName():String uppercase return the name in
setPrice(price: double): void-set the price to the price property
get Price():double - return the price
toString(): String - return the string format of the Product: id, name, price. The price is formatted with two decimal places. The name in uppercase
Write a class ProductList which extends from ArrayList (ArrayList is a collection) with the following information:
ProductList
Where:
+getProductById (id:int): Product
getProductById(id: int): Product -Find the product by id. If found then return product object, otherwise return a null value
+getProductWithMinPrice(): Product
getProductWithMinPrice(): Product return the product with the smallest price
Hints: to declare the ProductList class, you can use the following statement:
public class ProductList extends ArrayList<Product> {
}
The program output might look something like this (using the ProductList class):
The products have added:
The products have added:
The products have added:
Zoom
+ 100%
Close