Question: Please help me with this java class: The following requirements are for the SubcontractedPart class. Make this class a subclass of the ManufacturedPart class. Create

Please help me with this java class:

The following requirements are for the SubcontractedPart class.

Make this class a subclass of the ManufacturedPart class.

Create a default value constant for the subcontract cost. Name this DEFAULT_SUBCONTRACT_COST and initialize it to zero.

Create the three constructors described in the UML class diagram. The first two constructors should use 'this' to call the third constructor (the constructor with six parameters). Use a combination of arguments and default values for the necessary arguments. The third constructor should use "super" to call the superclass constructor passing the appropriate arguments. Create edits to ensure the subcontract cost cannot be negative. Throw the InvalidArgumentException if the subcontract cost is invalid. Use the public default constants from the Part and ManufacturedPart classes as needed in the SubcontractedPart class constructors.

Create a toString method that returns a String object containing the value of each data member. Use the @Override annotation. Display the class of the object using the getClass method. Call the toString method in the superclass to display the superclass data.

Create a public method named getTotalCost that returns the total cost from the super class plus the subcontract cost. Use the @Override annotation to insure this method overrides the method of the same name in the parent class.

Do not create additional data members or methods.

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

package Manage_Parts.src.edu.seminolestate.manage_parts;

import java.io.Serializable;

//Delilah Perez

public class SubcontractedPart extends ManufacturedPart implements Serializable { private static final long serialVersionUID = 1L; //private String processDescription; private double subcontractCost; public static final double DEFAULT_SUBCONTRACT_COST = 0; public SubcontractedPart(int id) throws InvalidProductionArgumentException //create minimal object { this(id, 0); } public SubcontractedPart(int id, double subcontractCost) throws InvalidProductionArgumentException { super (id, 0, 0); //call ManufacturedPart ctor this.setSubcontractCost(subcontractCost); } public SubcontractedPart(int id, String desc, double sellPrice, double laborCost, double materialCost, double subcontractCost) throws InvalidProductionArgumentException //for SubcontractedPart object { super(id, desc, sellPrice, laborCost, materialCost); this.setSubcontractCost(subcontractCost); } public double getProductCost () { return super.getProductCost() + subcontractCost; } public double getSubcontractCost() { return subcontractCost; } public void setSubcontractCost(double newSubcontractCost) throws InvalidProductionArgumentException { if (newSubcontractCost >= 0) subcontractCost = newSubcontractCost; else throw new InvalidProductionArgumentException("The subcontract price was invalid"); } @Override public String toString() { return super.toString() + " " + "\tProcess Description: " + this.getProcessDescription() + " " + "\tSubcontract Cost: " + this.getSubcontractCost(); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!