Write a program to create a class called ShapeObject and

 

Write a program to create a class called ShapeObject and this class contains the below,

1) String data field to called “Color”

2) Default constructor (no-arg) to create an object with “RED” color by default

3) An argument constructor to create the object with specified color. 

4) A method names toString() that returns the description of the ShapeObject.

Create a class called Triangle that extends from ShapeObject. The class contains:

1) Three double data fields called side1, side2 and side3

2) Default constructor (no-arg) that creates default Triangle with (1,1,1)

3) An argument constructor to create the object with specified side1, side2 and side3 values. 

4) An argument constructor to create the object with specified side1, side2 and side3 values and color from parent class. 

5) Accessor methods to all three data fields

6) Mutator methods to all three data fields

7) A method called getSemi_Perimeter() that returns Semi_Perimeter of the triangle

8) A method names toString() that returns the description of the Triangle.

Finally create a TestClass to create 3 objects for Triangle class. 

Sample Call in Test Program:

Triangle_Object_1 = Triangle()

Semi_Perimeter of Triangle_Object_1  = 1.5

Description of Triangle_Object_1  : Side1 = 1, Side2=1, Side3=1 and the color is RED and the Semi_Perimeter is 1.5

Triangle_Object_2 = Triangle(4,5,6)

Semi_Perimeter of Triangle_Object_2  = 7.5

Description of Triangle_Object_2  : Side1 = 4, Side2=5, Side3=6 and the color is RED and the Semi_Perimeter is 7.5

Triangle_Object_3 = Triangle(2,2,4,”GREEN”)

Semi_Perimeter of Triangle_Object_3  = 4.0

Description of Triangle_Object_3  : Side1 = 2, Side2=2, Side3=4 and the color is GREEN and the Semi_Perimeter is 4.0

Hint:

To calculate the Semi_Perimeter of the triangle, use the below formulae,

Semi_Perimeter = (a +b + c) / 2

Submission Requirement:

Please you need to submit your work in word format, and  each question should provide the below requirements:

  • The code 
  • The results in screenshots 

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

case study 1. How would you characterize the relationship between

case study  1. How would you characterize the relationship between Ola and its drivers? Include (a) drivers who  work directly for the company and earn a monthly wage, (b) gig drivers, (c) business owners who  themselves own/manage their own fleet and employ drivers, and (d) offline drivers.  2. Why is

Explain the Youth Firearms Violence Initiative. Choose one of the

  Explain the Youth Firearms Violence Initiative. Choose one of the strategies and tactics shown in Table 8.2 (p.246). Explain the program in depth and its effectiveness in reducing juvenile weapons crimes. Requirements: ·  2-3 pages double spaced ·  Use at least two reliable sources other than the text (not

Each article summary should be prepared with 5 separate paragraphs

Each article summary should be prepared with 5 separate paragraphs of text organized under separate section headings (e.g., Introduction, Methods, Results, Discussion, Stance). Your goal is to extract the key points from each section so the reader can read the review and understand the purpose, rationale, method, results, and implications

Case study Instructions is given in the ppt file. need

  Case study Instructions is given in the ppt file. need 2 pages, Please go through it. I attached the additional links to read in word file and two pdf file to read it too.  Complete the following Case Study Assignment: You’ve been working at a Pharmaceutical company for the

Use the Internet to look up some of the public

  Use the Internet to look up some of the public statements or speeches of an executive in a major corporation about a significant initiative such as entering into a joint venture or launching a new product line. What do you feel are the implications for making the internal and

Organizational/ Sport Culture – Premium Paper Help

Premium Paper Help is a professional writing service that provides original papers. Our products include academic papers of varying complexity and other personalized services, along with research materials for assistance purposes only. All the materials from our website should be used with proper references.

Prior to beginning work on this discussion, read Chapter 12:

Prior to beginning work on this discussion, read Chapter 12: The Capital Budgeting Decision in your textbook. Capital budgeting plays an important role in planning for capital expenditures. Regardless of one’s role or department in an organization, it is important to be familiar with the capital budgeting process in order

Katherine Mansfield’s “The Garden Party” Vol 2, pp. 1357-1366 Refer

Katherine Mansfield’s “The Garden Party” Vol 2, pp. 1357-1366 Refer to the grading rubric for this assignment using the link in the Gradebook. Step 2: Reflect “The Garden Party” is told as a third-person narrative, not as a first-person narrative. The difference is that a third-person narrative presents the characters

Read Nam Le’s short story Links to an external site.as

Read Nam Le’s short story Links to an external site.as well as the other linked readings.  The story references the My Lai massacre of the Vietnam War. Consider both the Turse and Le readings: How does events of the war inform the relationship between father and son? How does the

Throughout this course, you have been building all the various

  Throughout this course, you have been building all the various elements of your Final Evaluation Design (Final Project). As you know by now, research is an interactive process in which you use feedback to build your Final Evaluation Design. Throughout this course, you have received feedback from your instructor

When and how did you become aware of people being

  When and how did you become aware of people being treated differently because of race, culture, or religion? Explain. This discussion question meets the following NASAC Standards: 19) Understand the importance of self-awareness in one’s personal, professional, and cultural life. 85) Adapt counseling strategies to the individual characteristics of

Share your thoughts and opinions on consumer habits in media

  Share your thoughts and opinions on consumer habits in media in this week’s discussion. Think about the brands of products you buy: Are there brand name items you purchase regularly and without reasonable regard to price?  What has influenced you to choose or stick with a brand name item