Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Class Specifications The design specification of a class includes: 1) declarations for a list of instance fields (think of these as nouns) and 2) method

image text in transcribed

image text in transcribed

Class Specifications The design specification of a class includes: 1) declarations for a list of instance fields (think of these as nouns) and 2) method declarations (think of these as verbs), including parameters, which determine how objects are used. Implement a class, called MyPhone, with the following instance fields and methods. Do not create additional methods or make any changes to the following requirements. If you do, the automated tests will likely fail. Class Fields Declare meaningful names with appropriate data types for each of these private instance fields: an integer for the number of texts a double for the amount of data consumed (in megabytes) . a double for the remaining battery life (a value between 0.0 and 1.0) * a String for the customer name (e.g. "Amanda Johnson") * a String for the ten-digit phone number (e.g. "6163319999") * final doubles for the administrative fee, universal usage charge and base fee. Example private final double ADMINFEE-0.61; two final doubles for the video and audio usage per minute. For example private final double VIDEO-DATA-PER-MIN = 250 / 60.0; two final doubles for the maximum minutes of video and audio usage for a full battery charge. For example, audio streaming will last fifteen hours on a full charge . private final double AUDIO_MINUTES900.0; Phase 1 (20 pts) Constructor A constructor is a special method with the same name as the class and generally initializes the fields to appropriate starting values. Refer to section 5.8 . public MyPhone (String name, String num -this constructor initializes some of the instance members to zero and sets the customer name and number to the provided parameters. The phone starts fully charged (i.e. 1.0) Accessor Methods An accessor method does not modify class fields. The names for these methods, which simply return the current value of a field, often begin with the prefix get'. Refer to section 5.7 . public String getName ) - returns the customer name . public String getNumber - returns the phone number . public int getNumTexts returns the number of texts sent and received. . public double getBatteryLife -returns the remaining battery life . public double getDataUsage returns the amount of data used so far this month in megabytes (MB)

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

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

Effective Delivery Effective

Answered: 1 week ago