[CSC 204] "Plane" starter class...
Andrew J. Pounds
pounds_aj at mercer.edu
Fri Jan 30 08:43:34 EST 2009
Here is a starter class for your plane...
public class Plane {
/* Instance variables for the Plane class */
double DEFAULT_COST_PER_MILE = 0.095; // The cost per mile to
the airline
int maximumCapacity; // The maximum number of passengers the
plane will hold
int passengers; // The number of passengers on the plane
int totalCarryOnItems; // The number of carry on items on the plane
double ticketPrice; // The cost of a ticket
double costPerMile; // The cost per mile to the airline
double miles; // The number or miles the flight will
travel
String flightName; // The name of the flight
double revenue; // Money made on the flight
/* The ONLY Constructor */
public Plane (String name,
double flightMiles,
int maxPassengers,
double ticketCost) {
flightName = name;
miles = flightMiles;
maximumCapacity = maxPassengers;
ticketPrice = ticketCost;
totalCarryOnItems = 0;
passengers = 0;
costPerMile = DEFAULT_COST_PER_MILE;
revenue = 0.0;
}
/* Class methods */
public void board ( int boardingPassengers, int carryOnsPerPassenger) {
passengers = passengers + boardingPassengers;
totalCarryOnItems = totalCarryOnItems + carryOnsPerPassenger
* boardingPassengers;
}
public int getNumberOfPassengers(){
return passengers;
}
}
--
Andrew J. Pounds, Ph.D. (pounds at theochem.mercer.edu)
Associate Professor of Chemistry and Computer Science
Mercer University, Macon, GA 31207 (478) 301-5627
More information about the csc204
mailing list