📄 batch.java
字号:
import java.io.*;
import java.util.*;
import java.text.*;
import javagently.*;
class Batch {
/* The Batch class by J M Bishop Oct 1996
* --------------- Java 1.1 October 1997
* for products with sell-by-dates.
*
* To be used with the Coffees class
*/
Batch (double k, Date d) {
inStock = k;
sellByDate = d;
}
double available ( ) {
return inStock;
}
boolean sell (double k) {
inStock -= k;
System.out.println("Sold " + Stream.format(k,1,1)+ " from batch " +
DF.format(sellByDate));
return inStock <= 0; // sold out
}
void display () {
System.out.println("\t\t"+DF.format(sellByDate) +
" : " + Stream.format(inStock,4,1) + "kg");
}
private double inStock;
private Date sellByDate;
private DateFormat DF = DateFormat.getDateInstance(DateFormat.DEFAULT,
Locale.UK);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -