Question
complete the code public class Customer { // the Customer class has three fields private int custId; private String name; private boolean goldDude; // the
complete the code
public class Customer {
// the Customer class has three fields
private int custId;
private String name;
private boolean goldDude;
// the following will be used to automatically generate customer ids
//so they will be unique
private static int nextNum = 100;
// empty constructor
public Customer()
{
custId = nextNum;
nextNum++;
}
// constructor for creating a new customer where the id is
// automatically created
public Customer(String n)
{
name = n;
custId = nextNum;
nextNum++;
}
// full constructor
public Customer( String n, boolean gcm)
{
custId = nextNum;
nextNum++;
name = n;
goldDude = gcm;
}
// toString method
public String toString()
{
return name + " (custID: " + custId + ")";
}
//getters and setters
public int getCustId() {
return custId;
}
public void setCustId(int custId) {
this.custId = custId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNextNum() {
return nextNum;
}
public void setNextNum(int nextNum) {
this.nextNum = nextNum;
}
public boolean isGoldCardMember()
{
return goldDude;
}
public void setGoldCardMember(boolean goldCardMember) {
this.goldDude = goldCardMember;
}
}
import java.text.NumberFormat;
public class Rental {
// the Rental class has four fields
private Customer cust;
private Auto auto;
private int numDays;
private double rentalCost;
private char discount; // N = none G = gold D = days B = both
// all cars rent for $15.00 per day
final private double COST_PER_DAY = 15.00;
// TO DO!!write an empty and a full constructor
// toString method
//remember that each class should print out its own fields
// so we let the Auto and Customer class print out theirs
// this class only prints out the number of days field
@Override
public String toString()
{
NumberFormat nf = NumberFormat.getCurrencyInstance();
String string;
string = cust.toString() + " rented " ;
string = string + auto.toString() + " for " + numDays + " days.";
string = string + " The cost was " + nf.format(rentalCost) + " ";
switch (discount) {
case 'B':
string = string + "This person was both a gold card memeber and rented over six days and received a a 25% discount";
break;
case 'G':
string = string + "This person was a gold card memeber and received a a 10% discount";
break;
case 'D':
string = string + "This person rented over six days and received a 15% discount";
break;
case 'N':
string = string + "This person did not qualify for a discount";
}
return string;
}
// TO DO!!!the setRentalCost is where the cost is set
public void setRentalCost()
{
// give them a 15% discount if they rent over 6 days. Also Gold card members get an
//extra 10% off the original cost regardless of the number of days
// note next line is just a place holder. Also set the discount code
}
// generate getters and setters
}
public class Auto {
// the Auto class has two fields
private int year;
private String make;
private String model;
private String vin;
private double miles;
// empty constructor
public Auto()
{
}
// full constructor
public Auto(int year, String make, String model, String vin, double miles) {
this.year = year;
this.make = make;
this.model = model;
this.vin = vin;
this.miles = miles;
}
// toString method (the wording does not make sense until you realize
// that you will be calling this after calling the customer toString method
public String toString()
{
return "a " + year + " " + make + " " + model +
" with a VIN# of " + vin + " and a mileage of " + miles;
//return "a car with a vin of " + vin + " and a mileage of " + miles;
}
// getters and setters
public double getMiles() {
return miles;
}
public void setMiles(double miles) {
this.miles = miles;
}
public String getVin() {
return vin;
}
public void setVin(String vin) {
this.vin = vin;
}
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
}
import java.util.*;
import java.text.*;
public class WreckDriver {
public static void main(String[] args)
{
}
public static void loadNewData(ArrayList
{
a.add(new Auto(2009,"Ford" , "Mustang","ABC123", 1256.54));
a.add(new Auto(2010,"Chevy","Camero","QWI459", 33.98));
a.add(new Auto(1970,"Pink","Cadillac","950AKH", 212874.51));
a.add(new Auto(2007,"Lotus","Elise MkII","1A2D3F", 12859.90));
c.add(new Customer( "Brett Farve",false));
c.add(new Customer( "Bruce Springsteen",true));
c.add(new Customer( "Mickey Mouse", true));
c.add(new Customer( "Peyton Manning", true));
c.add(new Customer( "Donald Duck", true));
}
//Prints the cars that are available for rent
public static void showCars(ArrayList
{
}
// prints all the rentals that have been made
public static void printRentals(ArrayList
{
}
}
Customers:
1 Brett Farve (custID: 100)
2 Bruce Springsteen (custID: 101)
3 Mickey Mouse (custID: 102)
4 Peyton Manning (custID: 103)
5 Donald Duck (custID: 104)
Which customer? 2
This customer is a gold card member so we will treat him well!
The following cars are available to rent...
1. a 2009 Ford Mustang with a VIN# of ABC123 and a mileage of 1256.54
2. a 2010 Chevy Camero with a VIN# of QWI459 and a mileage of 33.98
3. a 1970 Pink Cadillac with a VIN# of 950AKH and a mileage of 212874.51
4. a 2007 Lotus Elise MkII with a VIN# of 1A2D3F and a mileage of 12859.9
Which auto? 3
How many days do you wish to have this beautiful vehicle? 10
Bruce Springsteen (custID: 101) rented a 1970 Pink Cadillac with a VIN# of 950AKH and a mileage of 212874.51 for 10 days.
The cost was $112.50
This person was both a gold card member and rented over six days and received a a 25% discount
More rentals (true/false)? true
Customers:
1 Brett Farve (custID: 100)
2 Bruce Springsteen (custID: 101)
3 Mickey Mouse (custID: 102)
4 Peyton Manning (custID: 103)
5 Donald Duck (custID: 104)
Which customer? 4
This customer is a gold card member so we will treat him well!
The following cars are available to rent...
1. a 2009 Ford Mustang with a VIN# of ABC123 and a mileage of 1256.54
2. a 2010 Chevy Camero with a VIN# of QWI459 and a mileage of 33.98
3. a 1970 Pink Cadillac with a VIN# of 950AKH and a mileage of 212874.51
4. a 2007 Lotus Elise MkII with a VIN# of 1A2D3F and a mileage of 12859.9
Which auto? 4
How many days do you wish to have this beautiful vehicle? 1
Peyton Manning (custID: 103) rented a 2007 Lotus Elise MkII with a VIN# of 1A2D3F and a mileage of 12859.9 for 1 days.
The cost was $13.50
This person was a gold card member and received a a 10% discount
More rentals (true/false)? true
Customers:
1 Brett Farve (custID: 100)
2 Bruce Springsteen (custID: 101)
3 Mickey Mouse (custID: 102)
4 Peyton Manning (custID: 103)
5 Donald Duck (custID: 104)
Which customer? 1
This customer is not a gold card member
The following cars are available to rent...
1. a 2009 Ford Mustang with a VIN# of ABC123 and a mileage of 1256.54
2. a 2010 Chevy Camero with a VIN# of QWI459 and a mileage of 33.98
3. a 1970 Pink Cadillac with a VIN# of 950AKH and a mileage of 212874.51
4. a 2007 Lotus Elise MkII with a VIN# of 1A2D3F and a mileage of 12859.9
Which auto? 1
How many days do you wish to have this beautiful vehicle? 15
Brett Farve (custID: 100) rented a 2009 Ford Mustang with a VIN# of ABC123 and a mileage of 1256.54 for 15 days.
The cost was $191.25
This person rented over six days and received a 15% discount
More rentals (true/false)? false
Rental summary:
Bruce Springsteen (custID: 101) rented a 1970 Pink Cadillac with a VIN# of 950AKH and a mileage of 212874.51 for 10 days.
The cost was $112.50
This person was both a gold card member and rented over six days and received a a 25% discount
Peyton Manning (custID: 103) rented a 2007 Lotus Elise MkII with a VIN# of 1A2D3F and a mileage of 12859.9 for 1 days.
The cost was $13.50
This person was a gold card member and received a a 10% discount
Brett Farve (custID: 100) rented a 2009 Ford Mustang with a VIN# of ABC123 and a mileage of 1256.54 for 15 days.
The cost was $191.25
This person rented over six days and received a 15% discount
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started