⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coffeeshop.java

📁 Java经典例程 从外国一大学计算机教授出版物下载的代码 经典
💻 JAVA
字号:
import java.io.*;
import java.util.*;
import java.text.*;
import javagently.*;
import myutilities.*;

class CoffeeShop {

   /* A test Coffee Shop program    by J M Bishop Oct 1996
    * --------------------------    Java 1.1 October 1997
    *                               updated August 2000
    * checks that data can be read into the
    * Coffee and Batch classes, and printed out again.
    * Uses an array to store several objects of each.
    */

  public static void main (String [] args) throws IOException {

    Stream in = Filer.open("coffee.dat");

    Coffee C [ ] = new Coffee [10];
    int kind;

    // Introductory messages
    System.out.println("Nelson's Coffee Shop");
    System.out.println("Inventory control");
    System.out.println("Stocking from coffee.data");

    // Read in the data for the coffees
    for (kind=0; kind<10; kind++) {
      try {
        C[kind] = new Coffee ();
        C[kind].prepareToStock (in);
        boolean morebatches = true;
        while (morebatches)
          morebatches = C[kind].newBatchIn (in);
      }
      catch (EOFException e) {
        System.out.println("That's the shop stocked for today\n");
        break;
      }
    }

    // Display all the details
    DateFormat DF = DateFormat.getDateInstance(DateFormat.FULL);
    System.out.println("The contents on " + DF.format(new Date()));
    for (int i = 0; i<kind; i++)
      C[i].display();
  }
}

⌨️ 快捷键说明

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