This repository was archived by the owner on Nov 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShopItemReservation.java
More file actions
84 lines (71 loc) · 2.26 KB
/
ShopItemReservation.java
File metadata and controls
84 lines (71 loc) · 2.26 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
import java.util.Date;
import java.util.*;
import java.io.*;
/**
* Write a description of class ShopItemReservation here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class ShopItemReservation
{
// instance variables
private String reservationNo;
private String itemID;
private String customerID;
private Date startDate;
private int noOfDays;
/**
* Constructor for objects of class ShopItemReservation
*/
public ShopItemReservation(String reservationNo, String itemID, String customerID, String startDate, int noOfDays)
{
this.reservationNo = reservationNo;
this.itemID = itemID;
this.customerID = customerID;
this.startDate = DateUtil.convertStringToDate(startDate);
this.noOfDays = noOfDays;
}
public ShopItemReservation() {}
public void printDetails()
{
System.out.println("");
System.out.printf("%-25s: %s\n", "Reservation No", reservationNo);
System.out.printf("%-25s: %s\n", "Item ID", itemID);
System.out.printf("%-25s: %s\n", "Customer ID", customerID);
System.out.printf("%-25s: %s\n", "Start Date", DateUtil.convertDateToShortString(startDate));
System.out.printf("%-25s: %s\n", "Reservation Length", noOfDays + " days");
}
public void writeData(PrintWriter pWriter)
{
pWriter.println(reservationNo + ", " + itemID + ", " + customerID + ", " + DateUtil.convertDateToShortString(startDate) + ", " + noOfDays);
}
public void readData(Scanner fieldScanner)
{
reservationNo = fieldScanner.next().trim();
itemID = fieldScanner.next().trim();
customerID = fieldScanner.next().trim();
startDate = DateUtil.convertStringToDate(fieldScanner.next().trim());
noOfDays = fieldScanner.nextInt();
}
public String getReservationNo()
{
return reservationNo;
}
public String getItemID()
{
return itemID;
}
public String getCustomerID()
{
return customerID;
}
public Date getStartDate()
{
return startDate;
}
public int getNoOfDays()
{
return noOfDays;
}
}