QuestionQuestion

Here is the ComputerPart interface:
public interface ComputerPart extends Comparable<ComputerPart> {
//Return the cost of this part in dollars
public double getCost();
//Set the cost of this part in dollars
public void setCost(double d);
//Return the name of the exactly part (note: There is no setter for this value!)
public String getName();
//Compares this to the parameter part, returning 1 if this is of higher cost
// than the parameter, 0 if the same, and -1 otherwise.
public int compareTo(ComputerPart part);
}

Implement the following classes: (use inheritance, classes of your own devising, and the IS-A relationship to save work)

• A RAM class that also stores and provides access (via getter and setter) to a capacity value, an integer value representing the gigabytes of data the RAM can store, and a latency value, a decimal value representing the amount of time to retrieve data. If toString() is called on an object of this class, return that it is RAM, the name, and what its cost, capacity, and latency are.

• A HardDisk class that also stores and provides access (via getter and setter) to a capacity value, an integer value representing the gigabytes of data the disk can store, and a latency value, a decimal value representing the amount of time to retrieve data. If toString() is called on an object of this class, return that it is a hard disk, the name, and what its cost, capacity, and latency are.

• A GraphicsCard class that also stores and provides access (via getter and setter) to a latency value, a decimal value representing the amount of speed it renders graphics. If toString() is called on an object of this class, return that it is a graphics card, the name, and what its cost and latency are.
• A Case class that stores only the most basic values required by the ComputerPart interface. If toString() is called on an object of this class, return that it is a case and what its cost is (no name).

• A FlashDrive class that also stores and provides access (via getter and setter) to a capacity value, an integer value representing the gigabytes of data the disk can store, a latency value, a decimal value representing the amount of time to retrieve data, and a value indicating whether it is an internal or external drive. If toString() is called on an object of this class, return that it is a flash drive, its name, whether it is internal, and what its cost, capacity, and latency are.

• A TapeDrive class that also stores and provides access (via getter and setter) to a capacity value, an integer value representing the gigabytes of data the disk can store, a latency value, a decimal value representing the amount of time to retrieve data, and its current position in the tape (initially 0). If toString() is called on an object of this class, return that it is a flash drive, its name, what position on the tape it is at, and what its cost, capacity, and latency are.

• A NoSuchPartException that is very basic, just the constructor with a string as input that calls the super constructor with that value.

Create two new classes, PartsNode and SortedPartsList. PartsNode should be a node for a linked list that stores any ComputerPart. SortedPartsList should be similar to SLinkedList in that it as a list of PartsNode inside of it. You may not use an array to complete this assignment!

• A default constructor that creates an empty linked list.
• A toString method that says that this is a sorted parts list then lists the parts that are in the list (in order).
• An averagePrice method that finds the average price of the stored data in the list and returns it (as a double).
• A method named insert that takes a ComputerPart and inserts a PartsNode containing that data at the correct position in the linked list. You may not simply insert the new node and then sort the list. For example, inserting a ComputerPart containing an item with cost $5 into a list of Parts with values $10 $7 $2 $0.40 results in a new list with nodes containing $10 $5 $7 $2 $0.40
• A method named delete that takes an index and removes that PartsNode in the list, returning its data to the user calling the method. If no such index exists (it's negative or beyond the end of the list), throw a NoSuchPartException.
• A searchAndRemove method that takes a String and uses linear search (the "simple" one) to find a ComputerPart with that name. If such a node storing that data is found, it deletes the node with the cheapest ComputerPart with that name from the linked list and returns the ComputerPart stored in the node. If such a node is not found, throw a NoSuchPartException.
• A static main method (as usual, the only static method or variable in this class!) that tests the above methods. At least one test per method is required.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class Case implements ComputerPart{   
    private double cost;
   
    /**
    * default constructor
    */
    public Case() {                  
       cost = 0;      
    }

    /**
    * constructor
    * @param cost
    */
    public Case(double cost) {
       this.cost = cost;
    }
      
    /**
    *
    * @return cost
    */
    @Override
    public double getCost() {
       return cost;
    }

    /**
    * setter cost
    * @param d
    */
    @Override
    public void setCost(double d) {
       cost = d;
    }

    /**
    * get name of part
    * @return
    */
    @Override
    public String getName() {
       return "Case";
    }...
$23.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats