Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Assignment | Prerequisite topics: Creating a template of a class The class definition vs. the client code Setter/getter methods Symbolic constants The default constructor

image text in transcribed
Lab Assignment | Prerequisite topics: Creating a template of a class The class definition vs. the client code Setter/getter methods Symbolic constants The default constructor The String class and String manipulation methods Duedate: 3 days Deliverables: As described by professor Sawh In this assignment, a celestial object is defined to be entities in the space. Example of celestial objects are comets, meteor, planets and stars. Every celestial object has a name, diameter and a temperature. The minimum diameter for a celestial object is 1 mile, and cannot have a temperature below 300 Kelvin. (You may assume that the temperature is a whole value. The diameter, on the other hand, can be a real number. The name of the celestial object, cannot be an empty string) Create a class named CelestialObject, objects of which will represent celestial objects emulated in the memory of the computer. The class contains the necessary accessor and mutator methods, to prevent the celestial object from attaining Invalid attribute values. Any attempt from the client to set the name of the object to an empty string, will result in the name being set to the string "N/A". Any attempt to set the diameter and temperature to invalid values, will result in them being set to their minimal values. The class will also contain a default constructor, which sets the name to the string "N/A", and the other attributes to their minimal values. To test the class, create the client code, which takes the actions listed below, in the order specified: creates a celestial object using the default constructor. It then prints the attributes of the this celestial object onto the screen. creates a second celestial object using the default constructor. It then prints the attributer of this celestial object onto the screen. Then using the object's accessor and mutato methodsl change the name, diameter and temperature to "CY-56", 4000 miles and Kelvin respectively. The object's attributes are then printed onto the screen (This test case checks the ability of the class to protect the name of the object) Create a thi celestial object, using the default constructor. The client would then print the attributes

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

Beginning PostgreSQL On The Cloud Simplifying Database As A Service On Cloud Platforms

Authors: Baji Shaik ,Avinash Vallarapu

1st Edition

1484234464, 978-1484234464

More Books

Students also viewed these Databases questions