编译型与解释型,两者各有利弊

前者由于程序执行速度快,同等条件下对系统要求较低,因此像开发操作系统、大型应用程序、数据库系统等时都采用它,像C/C++、Pascal/Object Pascal(Delphi)等都是编译语言。

而一些网页脚本、服务器脚本及辅助开发接口这样的对速度要求不高、对不同系统平台间的兼容性有一定要求的程序则通常使用解释性语言,如Java、JavaScript、VBScript、Perl、Python、Ruby、MATLAB 等等。

  1 package Com.Table;
  2 
  3 import java.util.ArrayList;
  4 import java.util.List;
  5 
  6 class Book
  7 {
  8     String Name;
  9     static int ID;
 10     String AuthoName;
 11     String PushName;
 12     int priceBook;
 13     static int NumBook;
 14     int totalBookNum;
 15  
 16     public String getName() {
 17         return Name;
 18     }
 19  
 20     public void setName(String Name) {
 21         this.Name = Name;
 22     }
 23  
 24     public static int getID() {
 25         return ID;
 26     }
 27  
 28     public static void setID(int ID) {
 29         Book.ID = ID;
 30     }
 31  
 32     public String getAuthoName() {
 33         return AuthoName;
 34     }
 35  
 36     public void setAuthoName(String strAuthoName) {
 37         this.AuthoName = strAuthoName;
 38     }
 39  
 40     public String getPushName() {
 41         return PushName;
 42     }
 43  
 44     public void setPushName(String strPushName) {
 45         this.PushName = strPushName;
 46     }
 47  
 48     public int getPriceBook() {
 49         return priceBook;
 50     }
 51  
 52     public void setPriceBook(int priceBook) {
 53         this.priceBook = priceBook;
 54     }
 55  
 56     public static int getNumBook() {
 57         return NumBook;
 58     }
 59  
 60     public static void setNumBook(int nNumBook) {
 61         Book.NumBook = nNumBook;
 62     }
 63  
 64     public int getTotalBookNum() {
 65         return totalBookNum;
 66     }
 67  
 68     public void setTotalBookNum(int totalBookNum) {
 69         this.totalBookNum = totalBookNum;
 70     }
 71  
 72     //添加
 73     List<Book> AddBook(String bookName, int Id, String authoName, String PushName, int priceBook, int numBook)
 74     {
 75         Book bk = new Book();
 76         List<Book> list = new ArrayList<Book>();
 77         bk.setName(bookName);
 78         Book.setID(Id);
 79         bk.setAuthoName(authoName);
 80         bk.setPushName(PushName);
 81         bk.setPriceBook(priceBook);
 82         bk.setTotalBookNum(Book.getNumBook() + numBook);
 83         list.add(bk);
 84         return list;
 85     }
 86  
 87     //查询
 88     Book SelectBook(List<Book> al, int ID)
 89     {
 90        
 91         for (int x = 0; x < al.size(); x++)
 92         {
 93             if (al.get(ID) != null)
 94             {
 95                 return al.get(ID);
 96             }
 97             else
 98             {
 99                 System.out.println("没找到!");
100             }
101         }
102         return null;
103     }
104  
105     //删除
106     void DeleteBook(List<Book> al, int ID)
107     {
108         Book bk = al.remove(ID);
109         if (bk != null)
110         {
111             System.out.println("删除成功!");
112         }
113     }
114 }
115  
116 public class SixteenTable {
117     public static void main(String []args)
118     {
119         Book bk = new Book();
120         List<Book> list = new ArrayList<Book>();
121         list = bk.AddBook("English", 1, "borter", "China Edition", 10, 10);
122         bk = bk.SelectBook(list, 0);
123         System.out.println("书名:" + bk.getName()
124                 + " 编号:" + Book.getID()
125                 + " 作者名:" + bk.getAuthoName()
126                 + " 出版社名:" + bk.getPushName()
127                 + " 书价:" + bk.getPriceBook()
128                 + " 册数:" + Book.getNumBook()
129                 + " 总数:" + bk.getTotalBookNum());
130         bk.DeleteBook(list, 0);
131  
132     }
133  
134 }

 

posted @ 2018-07-29 12:17  borter  阅读(745)  评论(0编辑  收藏  举报