-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.java
More file actions
36 lines (34 loc) · 1.13 KB
/
Transaction.java
File metadata and controls
36 lines (34 loc) · 1.13 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
//Name: Marco Bozic
//Student Number: 500896651
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
//Transaction class
public class Transaction
{
//various instance variables
int id;
Calendar date;
Car car;
String salesPerson;
String type;
double salePrice;
SimpleDateFormat sdf = new SimpleDateFormat("MM dd, YYYY");
//Transaction constructor
public Transaction(int id, Calendar date, Car car, String salesPerson, String type, double salePrice)
{
this.id = id;
this.date = date;
this.car = car;
this.salesPerson = salesPerson;
this.type = type;
this.salePrice = salePrice;
}
//method used to display transaction information as a String
public String display()
{
//SimpleDateFormat sdf = new SimpleDateFormat("EE MM/dd, YYYY");
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd, yyyy");
return "Transaction ID: " + id + " Date: " + sdf.format(date.getTime()) + " Transaction Type: " + type + " Salesperson: " + salesPerson + " Car: " + car.display();
}
}