Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data structure rcise #2 The purpose of this exercise is to verify that you know how to create classes, how to ate instance variables inside

Data structure image text in transcribed
rcise \#2 The purpose of this exercise is to verify that you know how to create classes, how to ate instance variables inside the classes and how to create objects. 1. Create a class called Shape. 2. Inside the Shape class create a public object variable called Sh type of type String. 3. Inside the Shape class create a public class variable called Sh no of type int. 4. Inside the School class create a privet object variable called Sh_color of type String. 5. Inside the School class create a constructor that intializes Sh_type and Sh_color to sent values. 6. Inside the School class create another constructor that initializes Sh_type to " an" and Sh_color to "n".. 7. write a method get color that returns the value of variable sh_color 8. write a method set_price that sets the value of variable Sh_color 9. Create a class called Exercise2. 10. In the Exercise2 class insert a main() method. 11. Inside the main() method, create three shape instances (objects) using the constructors defined in step 5 and 6. \[ \begin{array}{l} \text { Sh1: Sh_tYpe } \equiv \text { "Circle" and Sh_color }=\text { "Red" } \\ \text { Sh2: Sh_type } \equiv \text { "Square" and Sh_color ="Blue" } \\ \text { Sh3iai Sh_tYpe }={ }^{\text {"w" }} \text { and Sh_color }{ }^{\text {""*" }} \\ \end{array} \] 12. Assign 3 to the Sh_no class variable. 13. Print the Sh_tYpe and Sh_color for object Sh2

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

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions

Question

Acceptance of the key role of people in this process of adaptation.

Answered: 1 week ago

Question

preference for well defined job functions;

Answered: 1 week ago