goods.java

来自「用JAVA实现购物框程序,通过对JAVA面向对象思想的深入理解,采用JAVABE」· Java 代码 · 共 79 行

JAVA
79
字号
package shoppingBasket;

public class Goods {

	private String name ;
	private float price;
	private int count;

	public int getCount() {
		return count;
	}


	public void setCount(int count) {
		this.count = count;
	}


	public Goods() {
		// TODO Auto-generated constructor stub
	}
	

	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public float getPrice() {
		return price;
	}


	public void setPrice(float price) {
		this.price = price;
	}
	public void increase(){
		this.setCount(this.getCount()+1);
	}
	public void drop(){
		this.setCount(this.getCount()-1);
	}


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}


	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return this.name+" "+this.price+" "+this.count;
	}
	

	
	public boolean equals(Goods goods){
		if(name.equalsIgnoreCase(goods.name)){
				if(price==goods.price){
					return true;
				}
				return false;
			}
			return false;
	}
	

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?