zoukankan      html  css  js  c++  java
  • 【笔记】Eclipse and Java for Total Beginners—016

    Lesson 16 – Create main Method and JAR File

    • Introduce main method
    • Write a main method
    • Run MyLibrary as Java application
    • Export to JAR file and run from Windows

    在MyLibrary.java里添加main method。

    1 public static void main(String[] args) {
    2 // create a new MyLibrary
    3   MyLibrary testLibrary = new MyLibrary("Test Drive Library");
    4 Book b1 = new Book("War and Peace");
    5 Book b2 = new Book("Great Expectations");
    6 b1.setAuthor("Tolstoy");
    7 b2.setAuthor("Dickens");
    8 Person jim = new Person();
    9 Person sue = new Person();
    10 jim.setName("Jim");
    11 sue.setName("Sue");
    12
    13 testLibrary.addBook(b1);
    14 testLibrary.addBook(b2);
    15 testLibrary.addPerson(jim);
    16 testLibrary.addPerson(sue);
    17
    18 System.out.println("Just creat new library");
    19 testLibrary.printStatus();
    20
    21 System.out.println("Check out War and Peace to Sue");
    22 testLibrary.checkOut(b1, sue);
    23 testLibrary.printStatus();
    24
    25 System.out.println("Do some more stuff");
    26 testLibrary.checkIn(b1);
    27 testLibrary.checkOut(b2, jim);
    28 testLibrary.printStatus();
    29
    30 }
    31
    32 private void printStatus() {
    33
    34 System.out.println("Status Report of MyLibrary \n" +
    35 this.toString());
    36 for (Book thisBook : this.getBooks()) {
    37 System.out.println(thisBook);
    38
    39 }
    40
    41 for (Person p : this.getPeople()) {
    42 int count = this.getBooksForPerson(p).size();
    43 System.out
    44 .println(p + " (has " + count + " of my books)");
    45
    46 }
    47 System.out.println("Books Available: "
    48 + this.getAvailableBooks().size());
    49 System.out.println("--- End of Status Report ---");
    50
    51
    52 }

  • 相关阅读:
    jquery插件:web2.0分格的分页脚,可用于ajax无刷新分页
    Application共享数据
    WebClient类
    HttpResponse类
    IEqualityComparer<T>接口
    物理数据库设计 理解浮点数
    Server对象,HttpServerUtility类,获取服务器信息
    Linq to OBJECT之非延时标准查询操作符
    IComparer<T> 接口Linq比较接口
    会话状态Session
  • 原文地址:https://www.cnblogs.com/halflife/p/2079756.html
Copyright © 2011-2022 走看看