📄 product.java
字号:
public class Product
{
/* code */
private String code;
/* description */
private String description;
/* price */
private double price;
/**
* Constructs an <code>Product</code> object.
*
* @param initialCode a string with the code of the product.
* @param initialDescription a string that describes the product.
* @param initialPrice a double that represents the price of the product.
*/
public Product(String initialCode, String initialDescription, double initialPrice)
{
code = initialCode;
description = initialDescription;
price = initialPrice;
}
/**
* Returns the code of the product.
*
* @return code of the product.
*/
public String getCode()
{
return code;
}
/**
* Returns the description of the product.
*
* @return description of the product.
*/
public String getDescription()
{
return description;
}
/**
* Returns the price of the product.
*
* @return price of the product.
*/
public double getPrice()
{
return price;
}
/**
* Two <code>Product</code> objects are equal if their codes
* are equal (overrides the {@link Object#equals(Object)} method).
*
* @param object object with which this <code>Product</code>
* is to be compared.
* @return <code>true</code> if the argument is an
* <code>Product</code> object <i>and</i> the code of
* the argument is equal to the code of this
* <code>Product</code>; <code>false</code> otherwise.
*/
public boolean equals(Object object)
{
return (object instanceof Product) && getCode().equals(((Product)object).getCode());
}
/**
* Returns the string representation of this <code>Product</code>
* object (overrides the {@link Object#toString()} method).
*
* @return the string representation of this <code>Product</code>
* object.
*/
public String toString()
{
String message = getCode() + "_" + getDescription() + "_" + getPrice();
return message;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -