Hello,
First I'll like to say that this a fantastic site for newbies and I'm sure for seasoned programmers as well. I have gained a lot of insight by just reading the threads and for this I thank Daniweb.
Thank you very much in advance for your expert help.
My assignment is to creat 3 classes. All variables are private.
1) Customer class with - variables customername and customernum
2) Vehicle class - variables make, model, year and price
For 1 and 2 need methods - get, set, and default constructor
3) Create a Dealership class - variables slaesmanname
The salesman variable is private. Variable vehicles[] array of 5 vehicles
public class Customer {
//declare instance variable
private String customername; //name of customer
private int customernum; //customer number
//Constructors
Customer()
{ customername = "";
customernum = 0;
}
Customer(String n, int c)
{ customername = n;
customernum = c;
}
//getters
{ String getCustomername()
{ return customername; }
int getCustomernum()
{ return customernum; }
}
//setters
{ void setCustomername(String n)
{ customername = n; }
void setCustomernum()
{ customernum = c; }
}
}
}
-------------------------------------------------------------------------------
public class Vehicle {
//declare variables
private float price; //price
private int year; //year
private String make; //make
private String model; //model
//Constructors
Vehicle()
{ price = 0.00f;
year = 0;
make = "";
model = "";
}
Vehicle(float p, int y, String m, String d)
{ price = p;
year = y;
make = m;
model = d;
}
//declare methods
{ float getPrice()
{ return price; }
String getMake()
{ return make; }
}
{ void setPrice(float p)
{ price = p; }
void setMake(String m)
{ make = m; }
}
-----------------------------------------------------------------------------------------
public class Salesman {
//declare variables
private String salesmanname; //name of sales person
}
//Constructors
Salesman()
{ salesmanname = "";
}
Salesman(String m)
{ salesmanname = ("Joe Black");
}
------------------------------------------------------------------------------------------
public class Dealership {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//declare instance variable
//array of Vehicles
Vehicle v = new Vehicle();
Vehicle vehicles [] = new Vehicle[5]; int i;
vehicles[0].initializeVehicle(18000.00f, 2007, "Nissan", "Sentra");
vehicles[1].initializeVehicle(33000.00f, 2008, "Ford", "Mustang");
vehicles[2].initializeVehicle(25000.00f, 2009, "Chrysler", "Cherokee");
vehicles[3].initializeVehicle(40000.00f, 2007, "Ford", "F150");
vehicles[4].initializeVehicle(30000.00f, 2008, "Nissan", "Pathfinder");
//Loop through the array
for (int i = 0; i,5; 1++
{ if(v == vehicles[i].vehicle)
{ found = true;
match = i;
break;
}
else
{ found = false;
}
}
Salesman s = new Salesman();
}