Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8297923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:34:50+00:00 2026-06-08T15:34:50+00:00

I have a very weird question for my assignment and I was wondering how

  • 0

I have a very weird question for my assignment and I was wondering how to figure it out exactly.

The question asks:

  • Create a base class Shape which will form the basis of your shapes. The Shape class will contain functions to calculate area and circumference of the shape, plus provide the coordinates (Points) of a rectangle that encloses the shape (a bounding box). These will be overloaded by the derived classes as necessary. Create a display() function that will display the name of the class plus all stored information about the class (including area, circumference, and bounding box).

  • Build the hierarchy by creating the Shape classes Circle, Square, and Triangle. For these derived classes, create default constructors and constructors whose arguments can initialize the shapes appropriately using the correct number of Point objects (i.e., Circle requires a Point center and a radius; Square requires four Point vertices, while Triangle requires three Point vertices).

  • In main(), create one instance each of the following: a Circle with a radius of 23, a Square with sides 25, and a Triangle with sides 10, 20, 30. Define all of them so that the origin (0,0) is somewhere within each object. Display the information from each object.

So I need to figure out the points that will create a triangle with sides 10, 20, 30.

Input:

Triangle t(Point(0,0), Point(0,20), Point(0,30));

Here is my code for Triangle:

class Triangle : public Shape
{
   Point s1, s2, s3;

public:
  Triangle() {}
  Triangle(const Point &p1, const Point &p2, const Point &p3) : s1(p1), s2(p2), s3(p3) {}

  void bbox()
  {  
     std::cout << "Triangle::bounding " << s1 << s2 << s3;
  }   

  void circumference() 
  {
     Point side1 = (s1 - s2);
     Point side2 = (s2 - s3);
     Point side3 = (s3 - s1);

     std::cout << "Triangle::perimeter " << side1.dist() + side2.dist() +   side3.dist();
  }

  void area() 
  {
     Point side1 = (s1 - s2);
     Point side2 = (s2 - s3);
     Point side3 = (s3 - s1);

     double half = (side1.dist() + side2.dist() + side3.dist())/2;    
     double answer = sqrt(half * (half - side1.dist()) * (half - side2.dist()) * (half - side3.dist()));

     std::cout << "Triangle::area " << answer;     
  }

};

This is the output:

Triangle::bounding (0,0)(0,20)(0,30)
Triangle::perimeter 60
Triangle::area 0

What is the best method to create a bounding box around the Triangle with sides 10,20,30 or any triangle for that matter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:34:53+00:00Added an answer on June 8, 2026 at 3:34 pm

    There is no triangle with sides 10,20,30 with a non-zero area, so what you state is correct:

    Triangle::bounding (0,0)(0,20)(0,30)
    Triangle::perimeter 60
    Triangle::area 0

    But what you call bounding in that list is the corners of the triangle, not the bounding box.

    If this shape should actually be called a triangle is a matter of definition, but since that’s built in to the question I would not think too much about that. Either your teacher is trying to make you confused or he/she did not think it through.

    The bounding box ‘around (well, touching) any polygon is the rectangle with corners at

    (xmin,ymin)-(xmin,ymax)-(xmax,ymax)-(xmax,ymin)
    

    so, in your case

    (0,0) - (0,30) - (0,30) - (0,0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a very weird problem in chrome I just cannot figure out!
i know this question was asked before but i have this very weird beginner
Alright, I have some weird behavior and this question goes to the people out
I have one very weird question. There are 2 Silverlight Client 1. Admin 2.
So, I think I have a very weird question. So, let say that I
I have a very weird thing to do and simply don't know how. This
I have a very weird problem.. I really do hope someone has an answer
I have a very weird problem in Firefox ( version 3.5.2), and I am
I have a very weird problem with PROLOG. I have used it before, but
So, I have this very weird error - Some advanced PHP devs might also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.