forked from johnrogers104/PointOfSaleSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRental.java
54 lines (43 loc) · 1.32 KB
/
Rental.java
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
package ProcessSale;
// Import
import java.util.ArrayList;
import java.util.Date;
// Class to handle a rental
public class Rental extends Sale {
// Class variables
Date due;
// Constructor
public Rental() {
due = new Date();
}
// Get a rental to be returned
public void getRental(Date dateRented, String card) {
// implement in persistent storage
}
// Return an item that was rented
public boolean returnItem(String barcode, int qty) {
return storage.returnItems(barcode, qty);
}
// Override payment method to handle a rental (may not need to override this - ask John Rogers)
@Override
public boolean makePayment(String type) {
// Make sure payment is with a credit card
try {
Integer.parseInt(type);
} catch (NumberFormatException e) {
System.out.println("Error: not a credit card number");
return false;
}
Payment payment = new Payment(this, type);
payment.startRental();
storage.closeConnection();
return true;
}
// Finish a rental
public boolean endRental(String type) {
Payment payment = new Payment(this, type);
payment.endRental();
storage.closeConnection();
return true;
}
}