Question: Java programming problem; the Pasta and PastaType files are down below. In the Pasta exercise, we instantiated an object of a class, and called its

Java programming problem; the Pasta and PastaType files are down below.

Java programming problem; the Pasta and PastaType files are down below. Inthe Pasta exercise, we instantiated an object of a class, and called

In the Pasta exercise, we instantiated an object of a class, and called its methods. In this exercise, we will perform some modifications to that class. The APl of the class should all remain the same. The only API change we will make is the constructor parameters (as specified below). Although the API will largely remain the same, you may need to change method implementations to achieve the desired result Your task is to modify the Pasta class from the previous exercise. You are provided with an identical copy of the Pasta class. Refactor the name of the class to PastaNodified Next, change the constructor from PastaModified(String type, int price) PastaModified (PastaType type) You will need to update the rest of the class based on this new parameter, while still keeping all the method signatures (the method names and return types) unchanged. Take note of the parameters type PastaType, which refers to the provided enum PastaType.java. This allows you to use the methods in PastaType to enable you to write cleaner code. Because the method signatures must remain unchanged, you will need to figure out how to convert PastaType to a String (Hint: all object classes must implement tostring) ) package oop.PastaModified package oop. PastaNodified; public class Pasta [ public enum PastaType Private properties private int price: private String type: LINGUINE (10), SPAGHETTI (12), private int price: PastaType (int price) FETTUCCINE (14): Constructs a Pasta object with a price and a type public Pasta (Sering cype, int price) this.price- price this.type-type; this.price-price: public int price 0 return price: Gets the price of the pasta public int price) return price: Gets the type of the pasta public String type return type

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!