Project Requirements Each User Defined Class must be in its own separate source
ID: 3730632 • Letter: P
Question
Project Requirements Each User Defined Class must be in its own separate source text file. The source file name must be the same name as the class name in the source code. The NetBean IDE will assist you in creating separate class files using the File - New File Option from the pull down menu. Do not place more than one class description/ definition code in a single text file unless it is an inner class. The name of the class source file must be same name as the class. Create a Class named Person The first part of the assignment is to create a Super Class named Person. Create a basic UML Diagram for the Class named Person. After creating the Class Diagram, implement Class and the methods of your class from the Class Diagram using NetBeans. Requirements for the Person Class A Person has a first name, last name, and social security number. The class should contain the basic functionality of a user defined object described in Chapters 8. The basic functionality described in chapter 8 is that all user defined objects should have a get and set method for each attribute. A user defined object should have a default constructor and initialization constructor. A user defined object should have an overriding toString method. Create a Class named Employee The next segment of the assignment is to create a basic UML Diagram for an Employee Class and to create and implement the class for the Employee. First create the UML Class Diagram. After creating the Class Diagram, create and implement the Class and the methods of your Employee class from the UML Class Diagram. The Employee class should inherit from the Person class by extending it. Requirements for the Employee Class Create a class named Employee. An Employee has a hire date and an employee type. The Employee class should contain the basic functionality of a user defined object described in Chapters 8 of the textbook. The basic functionality described in chapter 8 is that all user defined objects should have a get and set method for each attribute. A user defined object should have a default constructor and initialization constructor. A user defined object should have an overriding toString method. Create a class named Administrator The next part of the assignment is to create a basic UML Diagram for an Administrator class. After creating the Class Diagram, implement the methods of your Administrator class. The Administrator class has only one attribute, the administrator type attribute. Requirements for the Administrator Class The Administrator class should contain the basic functionality of a user defined object described in Chapters 8 of the textbook. The basic functionality described in chapter 8 is that all user defined objects should have a get and set method for each attribute. A user defined object should have a default constructor and initialization constructor. A user defined object should have an overriding toString method. The Administrator Class should inherit from Employee. Create a class named Professor The next part of the assignment is to create a basic UML Diagram for an Professor class. After creating the Class Diagram, implement the methods of your Administrator class. The Administrator class has only one attribute, the Professor Rank attribute. Requirements for the Professor Class The Professor class should contain the basic functionality of a user defined object described in Chapters 8 of the textbook. The basic functionality described in chapter 8 is that all user defined objects should have a get and set method for each attribute. A user defined object should have a default constructor and initialization constructor. A user defined object should have an overriding toString method. The Professor Class should inherit from Employee. Create a class named Student The next part of the assignment is to create a basic UML Diagram for a Student class. After creating the Class Diagram, implement the methods of your Student class. The Student class has two attribute, the Student Type and Student Major Attributes. Requirements for the Student Class The Student class should contain the basic functionality of a user defined object described in Chapters 8 of the textbook. The basic functionality described in chapter 8 is that all user defined objects should have a get and set method for each attribute. A user defined object should have a default constructor and initialization constructor. A user defined object should have an overriding toString method. The Student Class should inherit from Person. Create a class named Graduate Student The next part of the assignment is to create a basic UML Diagram for a Graduate Student class. After creating the Graduate Class Diagram, implement the methods of your Student class. The Graduate Student class has only one attribute, the Thesis Title attribute. Requirements for the Graduate Student Class The Graduate Student class should contain the basic functionality of a user defined object described in Chapters 8 of the textbook. The basic functionality described in chapter 8 is that all user defined objects should have a get and set method for each attribute. A user defined object should have a default constructor and initialization constructor. A user defined object should have an overriding toString method. The Graduate Student Class should inherit from Student. Additionally for this class, it should contain the basic functionality that all user defined classes should have described and illustrated in Chapter 9. The basic functionality described is that every user defined class should also have a compareTo method and an overridden equals method. Create a class named Under Graduate Student The next part of the assignment is to create a basic UML Diagram for an Under Graduate Student class. After creating the Under Graduate Class Diagram, implement the methods of your Student class. The Under Graduate Student class has only one attribute, the Credit Hours attribute. Requirements for the Under Graduate Student Class The Under Graduate Student class should contain the basic functionality of a user defined object described in Chapters 8 of the textbook. The basic functionality described in chapter 8 is that all user defined objects should have a get and set method for each attribute. A user defined object should have a default constructor and initialization constructor. A user defined object should have an overriding toString method. The Under Graduate Student Class should inherit from Student. Additionally for this class, it should contain the basic functionality that all user defined classes should have described and illustrated in Chapter 9. The basic functionality described is that every user defined class should also have a compareTo method and an overridden equals method. Instantiate some instances of Graduate, Under Graduate, Administrator, and Professor Classes. Use your initialization constructor to give each instance an initial state. Use your default constructor to give an instance a default state. After giving an instance a default state, use your set methods to change the state of an object. Use the (to String) method of your Classes to print out the state of the instances of the Classes that were created in memory What You Need To Submit for this assignment Submit your UML Diagram in PDF Format Submit your Assignment Project as a Zipped NetBeans Project Folder Submit your Lab Report Submit all three documents separately in a single submission After completing the project in Netbeans, zip the project into a zip file. Upload the zipped file containing the Netbeans project folder that you created doing this assignment. Upload a copy of your Lab Report with your zipped NetBeans Project Folder and PDF of your UML Diagram.
Explanation / Answer
public class Main {
public static void main(String[] args) {
// TODO code application logic here
Vehicle car = new Vehicle();
Vehicle carCopy = new Vehicle();
FourByFour jeep1 = new FourByFour();
FourByFour jeep2 = new FourByFour();
FourByFour jeep2Copy = new FourByFour();
System.out.println(car.toString());
System.out.println(carCopy.toString());
System.out.println(jeep1.toString());
System.out.println(jeep2.toString());
System.out.println(jeep2Copy.toString());
// test set vin
car.setVinNumber("123456789a");
jeep1.setVinNumber("123456789b");
jeep2.setVinNumber("123456789c");
System.out.println("Setting Vin Numbers");
System.out.println(car.toString());
System.out.println(carCopy.toString());
System.out.println(jeep1.toString());
System.out.println(jeep2.toString());
System.out.println(jeep2Copy.toString());
// Test Copy
System.out.println("Copying Cars");
carCopy.copy(car);
jeep2Copy.copy(jeep2);
System.out.println(car.toString());
System.out.println(carCopy.toString());
System.out.println(jeep1.toString());
System.out.println(jeep2.toString());
System.out.println(jeep2Copy.toString());
// test compare
if (car.compareTo(carCopy) == 0) {
System.out.println("Cars Match");
System.out.println(car.toString());
System.out.println(carCopy.toString());
}
else {
System.out.println("no match");
}
if (jeep2Copy.compareTo(jeep2) == 0) {
System.out.println("Jeeps Match");
System.out.println(jeep2.toString());
System.out.println(jeep2Copy.toString());
}
else {
System.out.println("no match");
}
}
}
------------------------------------------------------------------------------------------------------------------------
public class FourByFour extends Vehicle {
double bayWidth, bayLength, bayHeight;
// constructor class with no values
public FourByFour(){
bayWidth = 0.0;
bayHeight = 0.0;
bayLength = 0.0;
}
public FourByFour (double w, double h, double l) {
bayWidth = w;
bayHeight = h;
bayLength = l;
}
public void setBayWidth (double w) {
bayWidth = w;
}
public void setBayLength (double l) {
bayLength = l;
}
public void setBayHeight (double h) {
bayHeight = h;
}
public double getBayWidth () {
return bayWidth;
}
public double getBayHeight () {
return bayHeight;
}
public double getBayLength () {
return bayLength;
}
public void copy(FourByFour v){
this.vinNumber = v.getVinNumber();
this.manufacturerName = v.getManufacturerName();
this.modelName = v.getModelName();
this.price = v.getPrice();
this.bayWidth = v.getBayWidth();
this.bayHeight = v.getBayHeight();
this.bayLength = v.getBayLength();
}
public int compareTo(FourByFour v) {
int x;
x = this.vinNumber.compareTo(v.vinNumber);
return x;
}
public String toString() {
return ("Vin: " + vinNumber + " || Manufacturer: " + manufacturerName
+ " || Model: " + modelName + " || Price: $" + price +
" || Bay Width: " + bayWidth + " || Bay Height: " +
bayHeight + " || Bay Length: " + bayLength);
} // end to String()
}
-------------------------------------------------------------------------------------------------------------------
public class Vehicle {
String vinNumber;
String manufacturerName;
String modelName;
double price;
// constructor class with no values ("no record")
public Vehicle(){
vinNumber = "12345";
manufacturerName = "Jeep";
modelName = "Commando";
price = 0.0;
}
public Vehicle (String vin, String manufacturer, String model,
double value) {
vinNumber = vin;
manufacturerName = manufacturer;
modelName = model;
price = value;
}
public void setVinNumber (String vin) {
vinNumber = vin;
}
public void setManufacturerName (String manuName) {
manufacturerName = manuName;
}
public void setModelName (String modelName){
this.modelName = modelName;
}
public void setPrice (double p){
price = p;
}
public String getVinNumber () {
return vinNumber;
}
public String getManufacturerName () {
return manufacturerName;
}
public String getModelName (){
return modelName;
}
public double getPrice (){
return price;
}
public void copy(Vehicle v){
this.vinNumber = v.getVinNumber();
this.manufacturerName = v.getManufacturerName();
this.modelName = v.getModelName();
this.price = v.getPrice();
}
public int compareTo(Vehicle v) {
int x;
x = this.vinNumber.compareTo(v.vinNumber);
return x;
}
public String toString() {
return ("Vin: " + vinNumber + " || Manufacturer: " + manufacturerName
+ " || Model: " + modelName + " || Price: $" + price);
} // end to String()
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.