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

a.Create a class named Order that performs order processing of a single item. Th

ID: 3641367 • Letter: A

Question

a.Create a class named Order that performs order processing of a single item. The class has the following five fields:
•Customer name
•Customer number
•Quantity ordered
•Unit price
•Total price


b.Include set and get methods for each field except the total price field. The set methods prompt the user for values for each field. This class also needs a method to compute the total price (quantity times unit price) and a method to display the field values.


c.Create a subclass named ShippedOrder that overrides computePrice() by adding a shipping and handling charge of $4.00. Write an application named UseOrder that instantiates an object of each of these classes. Prompt the user for data for the Order object, and display the results, then prompt the user for data for the ShippedOrder object, and display the results.


d.Save the files as Order. java, ShippedOrder. java, and UseOrder. java

--------------------------------------------------------------------------------

Explanation / Answer

I won't code everything for you but i'll get you started.

public class Order
{
String name;
int num;
int quantity;
double unitPrice;
double totalPrice;

public Order(String name, int num, int quantity, double unitPrice, double totalPrice)
{
this.name = name;
this.num = num;
this.quantity = quantity;
this.unitPrice = unitPrice;
this.totalPrice = totalPrice;
}

public String getName()
{
return this.name;
}

public int getNum()
{
return this.num;
}
public int getQuantity()
{
return this.quantity;
}

public double getUnitPrice()
{
return this.unitPrice;
}

public void setName(String name)
{
this.name = name;
return;
}

public void setNum(int num)
{
this.num = num;
return;
}
public void setQuantity(int quantity)
{
this.quantity = quantity;
return;
}

public void setUnitPrice(double unitPrice)
{
this.unitPrice = unitPrice;
return;
}

public double computePrice()
{
this.totalPrice = this.quantity*this.unitPrice;
return this.totalPrice;
}

}


/*
* The subclass is not fully implemented, but you should get an idea of how to do it by * viewing the class I created above
**/

public class ShippedOrder extends Order
{
//instance variables go here

//Constructor goes here

//get and set methods

//override computePrice method

public double computePrice()
{
//simply write the new implementation of computePrice here
}

}