📄 goods.java
字号:
import java.io.*;
public abstract class goods extends abs
{
double cost;
int num;
abs theAbs;
String item="goods";
public goods(double cost,int num, abs theAbs)
{
setCost(cost);
setNum(num);
this.theAbs=theAbs;
}
/*print the cost of every thing you buy */
public void display()
{
theAbs.display();
System.out.println(getItem()+" "+getCost()+" "+getNum()+" "+getAllCost());
}
/*some useful function but easy to understand*/
public double getCost()
{
return cost;
}
public void setCost(double cost)
{
this.cost=cost;
}
public double getAllCost()
{
return num*cost;
}
public double getNum()
{
return num;
}
public void setNum(int num)
{
this.num=num;
}
/*return the addtion of the cost of this goods and the cost of something you have bought*/
public double getFinalCost()
{
return theAbs.getFinalCost()+getAllCost();
}
public String getItem()
{
return item;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -