A Circle will have a radius.  The class will be able to keep track of the number of Circle objects created.  It will also hold the total of the circumferences of all the Circle objects created.          It will allow a client to create a Circle, passing in a double value for the radius into the Circle constructor. If the value for the radius that is passed in is 0 or negative, then the radius will be set to a value of 999.  The constructor should add 1 to the count of the number of Circles created. The constructor should call a method to calculate the circumference and then add the circumference for that object to an accumulator.    In addition to the constructor, the Circle class must have the following methods that return a boolean value:   isCongruent(Circle c) – Compares two Circle objects to determine if they are congruent (radii are equal). isValid() – the radius may not be 0 or negative.  equals (Triangle t) – compares two Triangle objects to determine if they are equal.  We will compare their circumferences to determine equality.   Additional methods in the Circle class   toString() – returns a String that specifies the value of the radius calcCircumference() – calculate and return the circumference of the object. calcArea() – calculate and return the area of the object addTotalCircumference().  This method will call calcCircumference() and add the circumberence for that object to an accumulator.  reduceTotalCircumference().  This method should subtract the circumference for that object from the accumulator. Accessor methods for all properties.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Class Circle

 

        A Circle will have a radius.  The class will be able to keep track of the number of Circle objects created.  It will also hold the total of the circumferences of all the Circle objects created. 

        It will allow a client to create a Circle, passing in a double value for the radius into the Circle constructor.

  • If the value for the radius that is passed in is 0 or negative, then the radius will be set to a value of 999. 

  • The constructor should add 1 to the count of the number of Circles created.

  • The constructor should call a method to calculate the circumference and then add the circumference for that object to an accumulator. 

 

In addition to the constructor, the Circle class must have the following methods that return a boolean value:

 

  • isCongruent(Circle c) – Compares two Circle objects to determine if they are congruent (radii are equal).

  • isValid() – the radius may not be 0 or negative. 

  • equals (Triangle t) – compares two Triangle objects to determine if they are equal.  We will compare their circumferences to determine equality.

 

Additional methods in the Circle class

 

  • toString() – returns a String that specifies the value of the radius

  • calcCircumference() – calculate and return the circumference of the object.

  • calcArea() – calculate and return the area of the object

  • addTotalCircumference().  This method will call calcCircumference() and add the circumberence for that object to an accumulator. 

  • reduceTotalCircumference().  This method should subtract the circumference for that object from the accumulator.

  • Accessor methods for all properties.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY