Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help Please as soon as possible!!! Netbeans Integrated Development Environment (

ID: 3880220 • Letter: H

Question

Help Please as soon as possible!!!

Netbeans Integrated Development Environment (IDE)

UML should be in Mord Document

Project Requirements

Each User Defined Class must be in its own separate source text file. 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 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 Product

The fist part of the assignment is to create a Super Class named Product. create a basic UML Diagram for the Class named Product. After creating the Class Diagram, implement Class and the methods of your class from the Class Diagram.

Requirements for the Product Class

A product has a product number, Purchased Price, and Sold Price. The class should contain the basic functionality of a user defined object.

Create a Class named Vehicle

The next segment of this part of the assignment in this module is to create a basic UML Diagram for a Vehicle class and to create the class for the Vehicle. First create the Class Diagram. After creating the Class Diagram, create and implement the Class and the methods of your Vehicle class from the Class Diagram. The Vehicle class should inherit from Product.

Requirements for the Vehicle Class

Create a class named Vehicle. A Vehicle has a VIN number, Model name, and selling price. The Vehicle class should contain the basic functionality of a user defined object.


Require Functionality in the Vehicle class

   Set methods for each property

   Get methods for each property

   Default and initialization Constructors

   toString Method

copy method

equals method

compareTo method

Create a class named FourByFour

The next part of this assignment for this module is to create a basic UML Diagram for a FourByFour Truck class. After creating the Class Diagram, implement the methods of your FourByFour class.The FourByFour class has a bayWidth, bayLength, and bayHeight property. The FourByFour class inherits from the Vehicle class

The FourByFour class should also contain the basic functionality of a user defined object.

The Four by Four Class should inherit from Vehicle.

Require Functionality in the FourByFour class

   Set methods for each property

   Get methods for each property

   Default and initialization Constructors

   toString Method

copy method

equals method

compareTo method

Instantiate some instances of your 4 By 4 Class. Use your initialization constructor to give an 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 4 By 4 Class to print out the state of the instances of the 4 By 4 Class that was created in memory

Explanation / Answer

Comment:

Created the class files as mentioned in the question. And I hope copy method override is the clone method which is used to create the copy of an object. All the best.

Code:

Product.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cheggappfourbyfour;

/**
*
* @author mmuzzami
*/
public class Product {

private int productNumber;
private double productPrice;
private double soldPrice;

@Override
public int hashCode() {
int hash = 5;
return hash;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Product other = (Product) obj;
if (this.productNumber != other.productNumber) {
return false;
}
if (Double.doubleToLongBits(this.productPrice) != Double.doubleToLongBits(other.productPrice)) {
return false;
}
if (Double.doubleToLongBits(this.soldPrice) != Double.doubleToLongBits(other.soldPrice)) {
return false;
}
return true;
}

public Product() {
}

@Override
public String toString() {
return "Product{" + "productNumber=" + productNumber + ", productPrice=" + productPrice + ", soldPrice=" + soldPrice + '}';
}

public Product(int productNumber, double productPrice, double soldPrice) {
this.productNumber = productNumber;
this.productPrice = productPrice;
this.soldPrice = soldPrice;
}

public int getProductNumber() {
return productNumber;
}

public void setProductNumber(int productNumber) {
this.productNumber = productNumber;
}

public double getProductPrice() {
return productPrice;
}

public void setProductPrice(double productPrice) {
this.productPrice = productPrice;
}

public double getSoldPrice() {
return soldPrice;
}

public void setSoldPrice(double soldPrice) {
this.soldPrice = soldPrice;
}
}

Vehicle.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cheggappfourbyfour;

import java.util.Objects;

/**
*
* @author mmuzzami
*/
public class Vehicle extends Product implements Comparable<Vehicle> {

private int vinNumber;
private String modelName;
private double sellingPrice;

@Override
public int compareTo(Vehicle o) {
// Comparing based on the model name
return this.modelName.compareToIgnoreCase(o.modelName);
}

public Vehicle() {
}

public Vehicle(int vinNumber, String modelName, double sellingPrice) {
super();
this.vinNumber = vinNumber;
this.modelName = modelName;
this.sellingPrice = sellingPrice;
}

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

@Override
public int hashCode() {
int hash = 5;
return hash;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Vehicle other = (Vehicle) obj;
if (this.vinNumber != other.vinNumber) {
return false;
}
if (Double.doubleToLongBits(this.sellingPrice) != Double.doubleToLongBits(other.sellingPrice)) {
return false;
}
if (!Objects.equals(this.modelName, other.modelName)) {
return false;
}
return true;
}

@Override
public String toString() {
return "Vehicle{" + "vinNumber=" + vinNumber + ", modelName=" + modelName + ", sellingPrice=" + sellingPrice + '}';
}

public int getVinNumber() {
return vinNumber;
}

public void setVinNumber(int vinNumber) {
this.vinNumber = vinNumber;
}

public String getModelName() {
return modelName;
}

public void setModelName(String modelName) {
this.modelName = modelName;
}

public double getSellingPrice() {
return sellingPrice;
}

public void setSellingPrice(double sellingPrice) {
this.sellingPrice = sellingPrice;
}
}

FourByFour.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cheggappfourbyfour;

/**
*
* @author mmuzzami
*/
public class FourByFour extends Vehicle implements Comparable<Vehicle> {

private int bayWidth;
private int bayLength;
private int bayHeight;

public int compareTo(FourByFour o) {
// Comparing based on the bay length
return (this.bayLength < o.bayLength) ? -1 : (this.bayLength > o.bayLength) ? 1 : 0;
}

@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone(); //To change body of generated methods, choose Tools | Templates.
}

@Override
public int hashCode() {
int hash = 5;
return hash;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final FourByFour other = (FourByFour) obj;
if (this.bayWidth != other.bayWidth) {
return false;
}
if (this.bayLength != other.bayLength) {
return false;
}
if (this.bayHeight != other.bayHeight) {
return false;
}
return true;
}

@Override
public String toString() {
return "FourByFour{" + "bayWidth=" + bayWidth + ", bayLength=" + bayLength + ", bayHeight=" + bayHeight + '}';
}

public int getBayWidth() {
return bayWidth;
}

public void setBayWidth(int bayWidth) {
this.bayWidth = bayWidth;
}

public int getBayLength() {
return bayLength;
}

public void setBayLength(int bayLength) {
this.bayLength = bayLength;
}

public int getBayHeight() {
return bayHeight;
}

public void setBayHeight(int bayHeight) {
this.bayHeight = bayHeight;
}

public FourByFour(int bayWidth, int bayLength, int bayHeight) {
super();
this.bayWidth = bayWidth;
this.bayLength = bayLength;
this.bayHeight = bayHeight;
}

public FourByFour() {
super();
}

}

FourByFourTest.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cheggappfourbyfour;

/**
*
* @author mmuzzami
*/
public class FourByFourTest {

public static void main(String[] args) {
FourByFour fbf = new FourByFour();
fbf.setBayHeight(20);
fbf.setBayLength(80);
fbf.setBayWidth(30);
System.out.println(fbf);
}
}

Output:

FourByFour{bayWidth=30, bayLength=80, bayHeight=20}