Question

Assignment Requirements

I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below

MotorVehical.pdf

Minimize File Preview

User Define Object Assignment:

Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results.

You are required to create three UML Class Diagrams for the classes that you are going to create and implement in the project.

For your UML Class Diagram for the Assignment, you can use any modeling tool you prefer. The only submission requirement is the document submitted is in PDF format with your name in the diagram

Create a Super Class named Motor_Vehicle. One of the requirements for the Motor_Vehicle class is that it is declared as an Abstract Class. The class has three properties and two abstract methods.

It has the following properties

  1. VIN
  2. manufacturer
  3. cost

The abstract methods are

  1. move_Forward
  2. move_Backward

The Motor_Vehicle class should have basic complement of concrete methods that all user defined objects should have.

  • constructors
  • set methods for the properties
  • get methods for the properties
  • an overriding toString method
  • a compare method
  • an equal method
  • a copy method

Chapter 9 describes an Interface Class. Create an Interface Class named Turn_Behavior that that contains the following Abstract Methods

turn_Left

turn_Right

The are two sub classes that inherit from the super class Motor_Vehicle. Each of the sub classes should implement the interface Turn_Behavior

  1. Car Class
  2. Cycle Class

The Car class should implement the Turn_Behavior interface. It has two properties

  1. capacity
  2. color

The Car class should also have the basic complement of concrete methods that all user defined objects should have.

  • constructors
  • set methods for the properties
  • get methods for the properties
  • an overriding toString method
  • a compare method
  • an equal method
  • copy method

The Cycle class should implement the Turn_Behavior interface. It has two properties

  1. number_Wheels
  2. seat_Type

The Cycle class should also have the basic complement of concrete methods that all user defined objects should have.

  • constructors
  • set methods for the properties
  • get methods for the properties
  • an overriding toString method
  • a compare method
  • an equal method
  • copy method

Development Environment Configuration

If you plan on working from home, you will need to have Intellij IDE installed on your personal computer. If you are not familiar with Netbeans, test and become familiar with the Intellij Integrated Development Environment (IDE). There are instructions in Canvas on getting the Intellij IDE installed on your personal computer. If working from home, you must have Intellij installed and configured.

All programming projects must be submitted as a zipped Intellij Project Folder

Project Requirements

Each User Defined Class must be in its own separate source text file. Multiple Class Declarations in a File will not be accepted. The source file name must be the same name as the class name in the source code. The Intellij 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.This project does not require the use of inner classes. The name of the class source file must be same name as the class.

Create a Class named Motor_Vehicle

The first part of the assignment is to create a Super Class named Motor_Vehicle. Before physically implementing the Motor_Vehicle class, create a basic UML Diagram for the Class named Motor_Vehicle. After creating the Class Diagram, implement the Class and the methods of your Motor_Vehicle class from the Class Diagram using Intellij .

Requirements for the Motor_Vehicle Class

A Motor_Vehicle has a VIN, manufacturer, and a cost.   The class should contain the basic functionality of a user defined object described in Chapters 8 and 9. 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, equals method and compare method.

Create a Class named Car

The next segment of the assignment is to create a basic UML Diagram for an Car Class and to create and implement the class for the Car. First create the UML Class Diagram. After creating the Class Diagram, create and implement the Class and the methods of your Car class from the UML Class Diagram. The Car class should inherit from the Motor_Vehicle class by extending it. It should also should implement the Turn_Behavior interface.

Requirements for the Car Class

Create a class named Car. An Car has a color and passenger capacity,   The Car class should contain the basic functionality of a user defined object described in Chapters 8 and 9 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, equals method and compare method

Create a class named Cycle. The Cycle should also should implement the Turn_Behavior interface.

The next part of the assignment is to create a basic UML Diagram for a Cycle class. After creating the Class Diagram, implement the methods of your Cycle class. The Cycle class has only two attributes, the number of wheels and seat type attributes.

Requirements for the Cycle Class

The Administrator class should contain the basic functionality of a user defined object described in Chapters 8 and 9 of the textbook. The basic functionality described in chapter 8 and 9 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, a equals method and a compare method The Cycle Class should inherit from Motor_Vehicle. It should also should implement the Turn_Behavior interface.

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 instances of the Cycle and Car 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 objects. Use the (to String) method of your Classes to print out the state of the instances of the Classes that were created in memory. Test the equals and Compare methods of the two classes. Use print statements to indicate that your overriding methods that override your inherited abstract methods are working.

Construct a text file containing records to test your program. The record structure and format is entirely up to you. However, the program must read the data used to test your classes and methods from a text. The may prompt for user input after using the text file. However, this i not required. A system that reads the data form a text file to instantiate and test the methods is required. MotorVehical Class Diagram Vehicle Inventory System Abstract Class with Two abstract methods VIN: String manufacture:String c

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*******************************MotorVehicle.java*************************/


/**
*
* @author Craig Nelson
*
*/
public abstract class MotorVehicle implements Comparable<MotorVehicle> {

   private String VIN;
   private String manufacturer;
   private double cost;

   public MotorVehicle() {
       super();
       VIN = "ABC";
       manufacturer = "EA";
       cost = 10000;
   }

   public MotorVehicle(String vIN, String manufacturer, double cost) {
       super();
       VIN = vIN;
       this.manufacturer = manufacturer;
       this.cost = cost;
   }

   public String getVIN() {
       return VIN;
   }

   public void setVIN(String vIN) {
       VIN = vIN;
   }

   public String getManufacturer() {
       return manufacturer;
   }

   public void setManufacturer(String manufacturer) {
       this.manufacturer = manufacturer;
   }

   public double getCost() {
       return cost;
   }

   public void setCost(double cost) {
       this.cost = cost;
   }

   public abstract void moveForward();

   public abstract void moveBackward();

   @Override
   public String toString() {
       return "MotorVehicle [VIN=" + VIN + ", manufacturer=" + manufacturer + ", cost=" + cost + "]";
   }

   @Override
   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (obj == null)
           return false;
       if (getClass() != obj.getClass())
           return false;
       MotorVehicle other = (MotorVehicle) obj;
       if (VIN == null) {
           if (other.VIN != null)
               return false;
       } else if (!VIN.equals(other.VIN))
           return false;
       if (Double.doubleToLongBits(cost) != Double.doubleToLongBits(other.cost))
           return false;
       if (manufacturer == null) {
           if (other.manufacturer != null)
               return false;
       } else if (!manufacturer.equals(other.manufacturer))
           return false;
       return true;
   }

   @Override
   public int compareTo(MotorVehicle o) {
       if (this.cost < o.cost) {
           return -1;
       }
       if (this.cost > o.cost) {
           return 1;
       }
       return 0;
   }

   @Override
   protected Object clone() throws CloneNotSupportedException {.
      
       return super.clone();
   }
  
  

}
/****************************************TurnBehavior.java****************************************************/


public interface TurnBehavior {

   public abstract void turnLeft();
   public abstract void turnRight();
}
/***********************************Car.java**********************************/

/**
*
* @author Criag Nelson
*
*/
public class Car extends MotorVehicle implements TurnBehavior {

   private int capacity;
   private String color;

   public Car() {
       super();
       capacity = 5;
       color = "White";
      

   }

   public Car(int capacity, String color) {
       super();
       this.capacity = capacity;
       this.color = color;
   }

   public Car(String vIN, String manufacturer, double cost, int capacity, String color) {
       super(vIN, manufacturer, cost);
       this.capacity = capacity;
       this.color = color;
   }

   public int getCapacity() {
       return capacity;
   }

   public void setCapacity(int capacity) {
       this.capacity = capacity;
   }

   public String getColor() {
       return color;
   }

   public void setColor(String color) {
       this.color = color;
   }

   @Override
   public String toString() {
       return "Car [capacity=" + capacity + ", color=" + color + "]" + super.toString();
   }

   @Override
   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (!super.equals(obj))
           return false;
       if (getClass() != obj.getClass())
           return false;
       Car other = (Car) obj;
       if (capacity != other.capacity)
           return false;
       if (color == null) {
           if (other.color != null)
               return false;
       } else if (!color.equals(other.color))
           return false;
       return true;
   }

   @Override
   public void turnLeft() {

       System.out.println("Turning Left!!");
   }

   @Override
   public void turnRight() {
       System.out.println("Turning Right!!");

   }

   @Override
   public void moveForward() {

       System.out.println("Moving Forward!!");
   }

   @Override
   public void moveBackward() {
       System.out.println("Moving Backword!!");

   }

   @Override
   public int compareTo(MotorVehicle o) {

       return super.compareTo(o);
   }

  
}
/******************************Cycle.java***************************/

/**
*
* @author Criag Nelson
*
*/
public class Car extends MotorVehicle implements TurnBehavior {

   private int capacity;
   private String color;

   public Car() {
       super();
       capacity = 5;
       color = "White";
      

   }

   public Car(int capacity, String color) {
       super();
       this.capacity = capacity;
       this.color = color;
   }

   public Car(String vIN, String manufacturer, double cost, int capacity, String color) {
       super(vIN, manufacturer, cost);
       this.capacity = capacity;
       this.color = color;
   }

   public int getCapacity() {
       return capacity;
   }

   public void setCapacity(int capacity) {
       this.capacity = capacity;
   }

   public String getColor() {
       return color;
   }

   public void setColor(String color) {
       this.color = color;
   }

   @Override
   public String toString() {
       return "Car [capacity=" + capacity + ", color=" + color + "]" + super.toString();
   }

   @Override
   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (!super.equals(obj))
           return false;
       if (getClass() != obj.getClass())
           return false;
       Car other = (Car) obj;
       if (capacity != other.capacity)
           return false;
       if (color == null) {
           if (other.color != null)
               return false;
       } else if (!color.equals(other.color))
           return false;
       return true;
   }

   @Override
   public void turnLeft() {

       System.out.println("Turning Left!!");
   }

   @Override
   public void turnRight() {
       System.out.println("Turning Right!!");

   }

   @Override
   public void moveForward() {

       System.out.println("Moving Forward!!");
   }

   @Override
   public void moveBackward() {
       System.out.println("Moving Backword!!");

   }

   @Override
   public int compareTo(MotorVehicle o) {

       return super.compareTo(o);
   }

  
}
/*********************************MotorVehicleTest.java**********************************/

/**
* @author Criag Nelson
*/
import java.util.ArrayList;

public class MotorVehicleTest
{

   public static void main(String[] args) {
       //create new arraylist and add motor vehicle objects
       ArrayList<MotorVehicle> motorVehicles = new ArrayList<>();
       MotorVehicle motorVehicle = new Car();
       MotorVehicle motorVehicle2 = new Car(10, "Blue");
       MotorVehicle motorVehicle3 = new Car("RJDLS", "HONDA", 3673631, 20, "RED");
       MotorVehicle motorVehicle4 = new Cycle();
       MotorVehicle motorVehicle5 = new Cycle(3, "double");
       MotorVehicle motorVehicle6 = new Cycle("EDJ", "Hero", 24000, 3, "Triple");
       motorVehicles.add(motorVehicle);
       motorVehicles.add(motorVehicle2);
       motorVehicles.add(motorVehicle3);
       motorVehicles.add(motorVehicle4);
       motorVehicles.add(motorVehicle5);
       motorVehicles.add(motorVehicle6);
       for (int i = 0; i < motorVehicles.size(); i++) {
          
           System.out.println(motorVehicles.get(i));
       }
       //Add your test
      
   }
}
/****************************output*************************/

Car [capacity=5, color=White]MotorVehicle [VIN=ABC, manufacturer=EA, cost=10000.0]
Car [capacity=10, color=Blue]MotorVehicle [VIN=ABC, manufacturer=EA, cost=10000.0]
Car [capacity=20, color=RED]MotorVehicle [VIN=RJDLS, manufacturer=HONDA, cost=3673631.0]
Cycle [wheels=2, seatType=Single]MotorVehicle [VIN=ABC, manufacturer=EA, cost=10000.0]
Cycle [wheels=3, seatType=double]MotorVehicle [VIN=ABC, manufacturer=EA, cost=10000.0]
Cycle [wheels=3, seatType=Triple]MotorVehicle [VIN=EDJ, manufacturer=Hero, cost=24000.0]
Console X <terminated> MotorVehicleTest [Java Application] C:\Program Files Java\ire1.8.0_131bin\javaw.exe (Mar 19, 2019, 9:3

Thanks a lot, Please let me know if you have any problem....................

Add a comment
Know the answer?
Add Answer to:
Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (The interface class-like) Assume you have the Edible interface with its abstract method. Design a class named Animal a...

    (The interface class-like) Assume you have the Edible interface with its abstract method. Design a class named Animal and its two subclasses named Mammal and Dairy. Make Sheep and Bear as subclasses of Mammal and make implement the Edible interface. howToEat() and sound() are the main two methods for all edible classes while sound() is the main method for the non-edible classes. 1. Draw the UML diagram for the classes and the interface 2. Use Arraylist class to create an...

  • java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectang...

    java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectangle, Triangle which extend the Shape class and implements the abstract methods. A circle has a radius, a rectangle has width and height, and a triangle has three sides. Software Architecture: The Shape class is the abstract super class and must be instantiated by one of its concrete subclasses: Circle, Rectangle, or...

  • Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEm...

    Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEmployee, HourlyEmployee which extend the Employee class and implements that abstract method. A Salary Employee has a salary, a Commision Employee has a commission rate and total sales, and Hourly Employee as an hourly rate and hours worked Software Architecture: The Employee class is the abstract super class and must be instantiated by one of...

  • Exercise 8 (The interface class-like) Assume you have the Edible interface with its abstract method Design...

    Exercise 8 (The interface class-like) Assume you have the Edible interface with its abstract method Design a class named Animal and its two subclasses named Mammal and Dairy. Make Sheep and Bear as subclasses of Mammal and make Chicken and Cow as subclasses of Dairy. The Sheep and Dairy classes implement the Edible interface. howToEat) and sound() are the main two methods for all edible classes while sound() is the main method for the non-edible classes. 1. Draw the UML...

  • Java code for the following inheritance hierarchy figure.. 1. Create class Point, with two private instance...

    Java code for the following inheritance hierarchy figure.. 1. Create class Point, with two private instance variables x and y that represented for the coordinates for a point. Provide constructor for initialising two instance variables. Provide set and get methods for each instance variable, Provide toString method to return formatted string for a point coordinates. 2. Create class Circle, its inheritance from Point. Provide a integer private radius instance variable. Provide constructor to initialise the center coordinates and radius for...

  • Part I (20%) [File: Student.java] Create a class called Student that has the following stored properties:...

    Part I (20%) [File: Student.java] Create a class called Student that has the following stored properties: • StudentID • First Name • Last Name Class Student should have read/write properties, constructor(s) and should implement the Academic interface. For academic methods, return zero for average, zero for credits and false for graduate. Also implement the toString() method that returns the above information as a String. Part II (5%) [File: Academic.java] Create an interface Academic that declares three methods: 1. average -...

  • The current code I have is the following: package uml; public class uml {        public...

    The current code I have is the following: package uml; public class uml {        public static void main(String[] args) {              // TODO Auto-generated method stub        } } class Account { private String accountID; public Account(String accountID) { this.accountID = accountID; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } @Override public String toString() { return "Account [accountID=" + accountID + "]"; } } class SuppliesAccount extends Account { private...

  • JAVA Problem:  Coffee    Design and implement a program that manages coffees. First, implement an abstract class...

    JAVA Problem:  Coffee    Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public void prepare (); } The prepare method will...

  • Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named...

    Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type(does not mention the data type of the variable coffeeType), price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public...

  • Create an Item class, which is the abstract super class of all Items.           Item class...

    Create an Item class, which is the abstract super class of all Items.           Item class includes an attribute, description of type String for every item. [for eg. Book]                                                             A constructor to initialize its data member of Item class.               Override toString() method to return details about the Item class. Create the ExtraCharge interface with the following details.                       Declare a constant RATE with value 0.25   Declare a method called calculateExtraCharge(), which returns a double value. Create the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT