Repository navigation
Expand file tree
/
Copy pathBook.java
More file actions
91 lines (83 loc) · 1.89 KB
/
Copy pathBook.java
File metadata and controls
91 lines (83 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import java.util.ArrayList;
/*
* This class represents a book. it stores data and formats a string about the book.
*/
public class Book {
public enum g {NINE,TEN,ELEVEN,TWELVE,AP};
public static final String sep=" | ";
private String title;
private BookOrder storageRoom;
private int total;
private ArrayList<BookOrder> orders=new ArrayList<BookOrder>();
private double price=0;
private String isbn="";
private g grade;
private int missing;
public Book(String t,BookOrder bo,int tot,double p,String i,g grd,int miss){
this.title=t;
this.storageRoom = bo;
this.total = tot;
this.price = p;
this.isbn = i;
this.grade = grd;
this.missing=miss;
}
public String getTitle() {
return title;
}
public BookOrder getStore() {
return storageRoom;
}
public int getTotal() {
return total;
}
public ArrayList<BookOrder> getOrders() {
return orders;
}
public void setOrders(ArrayList<BookOrder> orders) {
this.orders = orders;
}
public double getPrice() {
return price;
}
public String getIsbn() {
return isbn;
}
public g getGrade() {
return grade;
}
public int getMissing(){
return missing;
}
public void addOrder(BookOrder b){
orders.add(b);
}
private String toLength(String a, int l,char pad){
if(a.length()>=l){
return a.substring(0,l);
}
while(a.length()<l){
a+=""+pad;
}
return a;
}
public void saveOrds(String file){
}
/**
* Returns a String formatted for the list GUI.
*/
public String toString(){
String r=" "+toLength(title,25,' ')+sep;
r+=""+toLength(""+total,3,' ')+""+ sep;
r+=""+toLength(""+storageRoom.getRoom(),3,' ')+""+ sep;
r+=""+toLength(""+storageRoom.getNum(),4,' ')+""+ sep;
r+=""+toLength(""+(int)price+"."+toLength(""+(int)(price*100%100),2,'0'),6,' ')+""+sep;
r+=toLength(isbn,20,' ')+sep;
if(!grade.equals(g.AP)){
r+=toLength(""+(grade.ordinal()+9),2,' ');
}else{
r+="AP";
}
return r;
}
}