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

A construction crew is lengthening a road. Let L be

A construction crew is lengthening a road. Let L be the total length of the road (in miles). Let D be the number of days the crew has worked. Suppose that L=2D + 400 gives L as a function of D. The crew can work for at most 90 days.Identify

Write a 1200+ word paper in a Word document format

Write a 1200+ word paper in a Word document format (.doc or .docx) about the topic that you will receive via email.  Include a bibliography. Use at least 3 sources which can all be web-based. The 3-Motions of the Earth: the Rotational Motion, the Revolution, the Precession, and their impact

Primary Discussion Response is due by Friday (11:59:59pm Central), Peer

Primary Discussion Response is due by Friday (11:59:59pm Central), Peer Responses are due by Tuesday (11:59:59pm Central). Primary Task Response: Within the Discussion Board area, write 300-500 words that respond to the following questions with your thoughts, ideas, and comments. This will be the foundation for future discussions by your

HSC 3485 Rasmussen University Healthcare Advocacy Discussion Nursing Assignment Help

Directions: Healthcare advocates have an essential role in today’s health system. Advocates may work with healthcare facilities, providers, insurance companies, or patient groups. Be able to identify and establish necessary roles for each group. For your initial discussion post, please provide two different scenarios in which healthcare advocates may be

Imagine that you are an immigrant arriving in a new

  Imagine that you are an immigrant arriving in a new country. Perhaps you are escaping persecution, famine, or war, or simply pursuing a better life. Perhaps you are detained at the border. You do not have any support networks in this new country, or if you do, they are

The Bible contains many passages that seem immoral to follow.

The Bible contains many passages that seem immoral to follow. For example, Exodus 21:20-21, Leviticus 25:44-46, Ephesians 6-5 and Titus 2:9-10 all endorse slavery.   I Corinthians 14:34 commands women to stay silent in church. Deuteronomy 22:28 states that when a virgin has premarital sex (the text is vague about her consent, so the

In your first paragraph, summarize what King’s major points are

In your first paragraph, summarize what King’s major points are in the letter. Consider: What was the purpose of the Letter from a Birmingham Jail?  Why was King more troubled by the White moderate than the KKK?  What does King view as the reason for law and order, and how is

4-1 Discussion: Reflection on Daily Good

 Description Part A: In your post, choose one product you use every day and describe the design, production, and packaging of the item. Do you notice anything exemplary about the design or packaging of the item in terms of sustainability? Is there something particularly wasteful or needlessly harmful that you

Use 4 of the 5 topics below discuss300-500 words in

Use 4 of the 5 topics below discuss300-500 words in length  1. Name the 7 types of analysis discussed in this course and choose 2 to compare and contrast.2. Describe the pros and cons of the electoral system.3. Describe the differences and similarities between a nation and state.4. Compare and

Different national cultures have different viewpoints of creativity

Different national cultures have different viewpoints of creativity and innovation. Using two countries of your choice, explain how these different viewpoints can affect business relationships between your chosen two countries. US and Germany    Need 15 ACADEMIC references, Enrich your synthesis with illustrations to underpin theories and your arguments. Diagrams,

Discussion: Applying Middle Range Theories to Practice Post your responses to the Discussion based on the course requirements. Your Discussion postings should be written in standard edited English and Nursing Assignment Help

Discussion: Applying Middle Range Theories to Practice Post your responses to the Discussion based on the course requirements. Your Discussion postings should be written in standard edited English and follow APA guidelines as closely as possible given the constraints of the online platform. Be sure to support your work with

Assignment: Somatic Symptom Disorders Individuals with somatic symptom disorders tend

Assignment: Somatic Symptom Disorders Individuals with somatic symptom disorders tend to have considerable difficulty with how they experience and appraise their bodily symptoms. The illness and the dysfunctional focus and behavior around the illness can assume a central role in the person’s life. Somatic symptom disorders were originally thought of

You are a CEO of a tech company in California

You are a CEO of a tech company in California and you will be presenting to a group of technology professionals in a country of your choice; prepare a short audience profile of your audience and their needs. Conduct research to learn about your country and expectations of your audience

Answer each of the following questions: Explain and provide an

Answer each of the following questions: Explain and provide an example of polymorphism. Do not use the same examples featured in the learning materials. Explain and provide an example of encapsulation. Do not use the same examples featured in the learning materials. What is the utility, benefits, and challenges of