// Program Name:
SoldCar.java
// Course:
CSE 1302J
// Student Name:
Bradley Shedd
// Assignment Number:
Project#3
// Due Date:
10/20/2010
// Purpose:
This program is derived from Car.java
//
The price, customer, date sold, and profit
//
will be called to print. The profit is calculated
//
in the same toString.
public
class SoldCar
extends
Car
{
private
double price;
private
String customer;
private
Date dateSold;
public
SoldCar(
double dcIn,
int
idIn, Date dateArrIn,
double
priceIn, String customerIn, Date dateSoldIn, String m,
int
y)
{
super
(dcIn, idIn, dateArrIn, y, m);
price = priceIn;
customer = customerIn;
dateSold = dateSoldIn;
}
public
SoldCar(Car carin,
double
priceIn, String custIn, Date dateSoldIn)
{
super(carin.cost,
carin.idNum, carin.date, carin.year, carin.model);
price= priceIn;
customer = custIn;
dateSold = dateSoldIn;
}
public
double getPrice()
{
return
price;
}
public
String getCustomer()
{
return
customer;
}
public
Date getDateSold()
{
return
dateSold;
}
public
double calcProfit()
{
return
price-cost;
}
public
String toString()
{
return
super.toString() +
"\nPrice:\t\t"
+
"$ " + price +
"\nCustomer:\t"
+ customer +
"\nDate sold:\t"
+ dateSold +
"\nProfit:\t\t"
+
"$ " + calcProfit() +
"\r________________________________";
}
public
boolean equals(SoldCar other)
{
return
super.equals(other)&&
dateSold.equals(other.dateSold);
}
}