-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProduct.java
43 lines (42 loc) · 892 Bytes
/
Product.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
A product in a vending machine.
*/
public class Product
{
private String description;
private double price;
/**
* Product() - Contrructs a product object
* @param aDescription the description of the product
* @param aPrice the price of the product
*/
public Product(String aDescription, double aPrice)
{
description = aDescription;
price = aPrice;
}
/**
* getName() - gets the name of product
* @return name Returns name of product
**/
public String getName()
{
return description;
}
/**
* getPrice() - gets the price
* @return price Returns the price of product
**/
public double getPrice()
{
return price;
}
/**
* toString() - return the description and price
* @return description, price This returns the description and price of product
**/
public String toString()
{
return description + ", " + price;
}
}