Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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 typeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started