// Program Name:
Car.java
// Course:
CSE 1302J
// Student Name:
Bradley Shedd
// Assignment Number:
Project#3
// Due Date:
10/20/2010
// Purpose:
This program includes the cost, ID number, date,
//
model make and year of a car. This program will be called
//
into the SoldCar.java and check if two cars are the same.
//
There is an equals method at the bottom.
public
class Car
{
protected
int idNum;
protected
double cost;
protected
Date date;
protected
String model;
protected
int year;
public
Car(double c,
int
id, Date d,
int y, String m)
{
cost = c; idNum = id; date = d;model = m; year = y;
}
public
double getCost()
{
return
cost;
}
public
int getID()
{
return
idNum;
}
public
Date getDate()
{
return
date;
}
public
String toString()
{
return
"ID NUM:\t\t" + idNum +
"\nDEALER COST:\t" +
"$ "
+ cost +
"\nDATE ARRIVED:\t" + date;
}
public
boolean equals (Car o)
{
return
model.equals(o.model) &&
date.equals (o.date)&& year==o.year;
}
}
C
5000.00 1234 January 1 2004 2000 Honda_Accord
S1 1234 6000.00 Roth February 15 2004
S2 8000.00 2222 January 15 2004 1999 Ford_F150 9500.00 Jones January 25 2004
C 14000.00 3333 June 6 2003 1999 GMC_Suburban
C 5000.00 1222 January 1 2004 2000 Honda_Civic
C 10000.00 4444 July 10 2002 2001 Toyota_Tundra
S2 12000.00 5555 February 6 2003 1965 Ford_Mustang 15000 Williams September 4
2003
S1 3333 15650 Brown December 25 2003
C 10500.00 4000 July 10 2002 2001 Toyota_Tundra
S2 9500.00 6666 January 21 2004 1999 Ford_F150 9000.00 Smith January 31 2004
C 5000.00 1222 January 1 2004 2000 Honda_Civic
S2 8000.00 2222 January 15 2004 1999 Ford_F150 9500.00 Jones January 25 2004
S2 9900.00 6667 January 21 2004 1999 Ford_F150 9007.00 Byrd January 31 2004
X