Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions