Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You Do It Creating a Class that Contains Instance Fields and Methods 153 Next, you create a class to store information about event services offered

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
You Do It Creating a Class that Contains Instance Fields and Methods 153 Next, you create a class to store information about event services offered at Paradise Day Spa. 1. Open a new document in your text editor, and type the following class header and the curly braces to surround the class body: public class SpaService Between the curly braces for the class, insert two private data fields that will hold data about a spa service: private String serviceDescription; private double price; Within the class's curly braces and after the field declarations, enter the following two methods that set the field values. The setServiceDescriptionO method accepts a String parameter and assigns it to the serviceDescription field for each object that eventually will be instantiated. Similarly, the setPriceO method accepts a double parameter and assigns it to the price field. Note that neither of these methods is static public void setServiceDescription(String service) 2. 3. serviceDescription-service; public void setPrice(double pr) price = pr ; Next, add two methods that retrieve the field values as follows: public String getServiceDescriptionO 4. return serviceDescription public double getPriceO return price; Save the file as SpaService.java, compile it, and then correct any syntax errors. Remember, you cannot run this file as a program because it does not contain a public static mainO method. After you read the next section, you will use this class to create objects. 5

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_2

Step: 3

blur-text-image_3

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions