This repository was archived by the owner on Dec 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBill.java
More file actions
81 lines (68 loc) · 2.09 KB
/
Copy pathBill.java
File metadata and controls
81 lines (68 loc) · 2.09 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
package com.library.component;
import com.library.util.Day;
public class Bill {
private String status;
private Person person;
private Book[] books;
private Day borrowDay;
private Day returnDay;
private double price;
public Bill() {
this.status = "";
this.books = new Book[0];
this.borrowDay = new Day();
this.returnDay = new Day();
this.price = 0.0;
}
public Bill(String status, Person person, Book[] books, Day borrowDay, Day returnDay, double price) {
this.status = status;
this.person = person;
this.books = books;
this.borrowDay = borrowDay;
this.returnDay = returnDay;
this.price = price;
}
public String getStatus() {
return status;
}
public Book[] getBooks() {
return books;
}
public Person getPerson() {
return person;
}
public Day getBorrowDay() {
return borrowDay;
}
public Day getReturnDay() {
return returnDay;
}
public double getPrice() {
return price;
}
public void hasReturned() {
status = "Returned";
}
public void output() {
char check = ' ';
if (status.equals("Returned"))
check = '\u2713'; // '✓'
System.out.printf("%c |%10d |%24s |%30s | ", check, person.getId(), person.getName(), books[0].getName());
System.out.println(borrowDay + " | " + returnDay + " | " + price);
String temp = "";
for (int i = 1; i < books.length; i++)
System.out.printf(" |%10s |%24s |%30s |%12s |%12s |\n", temp, temp, books[i].getName(), temp, temp);
}
@Override public String toString() {
String bookList = books[0].getName();
for (int i = 1; i < books.length; i++)
bookList += " / " + books[i].getName();
return status + ", " +
person.getId() + ", " +
person.getName() + ", " +
bookList + ", " +
borrowDay + ", " +
returnDay + ", " +
price;
}
}