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

  • Home
  • SEARCH
  • 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 8682389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:45:33+00:00 2026-06-12T21:45:33+00:00

The below question is confusing me, I am not sure if my thinking is

  • 0

The below question is confusing me, I am not sure if my thinking is right. This is the question

Given three straight lines a, b & c. They will be able to form a
triangle provided that sum of any two lines is always greater than the
third line (i.e. a + b > c and b + c > a and a + c

b). Write a Java class Triangle with the following:

Attributes: length of the three sides of the triangle 
Behaviour:
  • Constructor that sets the length of the three sides to the values passed in. The constructor should throw an InvalidValueException
    object when the values are not able to form a triangle.

    • findArea() method to calculate the area of the Triangle object using the formula area = a +b+c

Just a heads up the next part of the question is to create a GUI. I already did that.

So the above question is it asking me to just simply get the values, but from where? Is it through the GUI? or Commandline base? the question was not specific so can I assume that simmply create variables that are ready to accept the values?

  • 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-12T21:45:36+00:00Added an answer on June 12, 2026 at 9:45 pm

    Why not just hardcode it for the moment in a test class or similar e.g.

    new Triangle(3,4,5);
    

    In this scenario you’re interested in testing your code for various functions (valid vs. invalid) and so I would write a test (or multiple tests) that have particular sets of data e.g.

       // expected to be ok
       new Triangle(3,4,5);
    
       // expected exception
       new Triangle(1,1,3);
    

    In the latter case you’d want to catch the exception and bail out of your program with an error if you don’t get an exception.

    You might want to check out unit test frameworks to help you with this.

    Edit: Your amended question now contains setters for the Triangle sides. I think you’re better off making the fields read only, doing this on construction and throwing an Exception from the constructor. If you need setters, then you have to call the validate() method at some stage otherwise you’re potentially creating a Triangle which is invalid. Note that you can’t call the validator upon each setter invocation since you may be setting multiple sides and an intermediate state may be invalid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a confusing question but I have written below a Directory crawler,
I'm really not sure how to word this question, but here goes... I have
Not sure how to title my question... lol. Below is what i am needing.
I am not sure if I am doing this right. I have a list
I'm not exactly sure how to word this question, so sorry in advance for
This is with reference to the below question: Execute program from within a C
Given the sample console application below: QUESTION #1 : Why does .Name() return typeof
In a recent interview I was asked below question. Given a set of nodes
The question below is not really a programming question, but more of how can
UPDATE: I recently learned from this question that in the entire discussion below, I

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.