Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Too many circles!!! You may reuse code from Part 3 to create a TooManyCirclesTester class. At this point, you have likely noticed that the code

  1. Too many circles!!!

You may reuse code from Part 3 to create a TooManyCirclesTester class. At this point, you have likely noticed that the code is getting quite long and repetitive. Lets simplify some of our code to be less wasteful.

  • Update your Circle class to have a new private attribute of type String named name

  • Update your Circle class to have new public methods for getting and setting the attribute name

  • Update your Circle class to have a public constructor that takes two parameters:

    • The first parameter should be a double named rad

    • The second parameter should be a String named circleName

  • Inside of the constructor, call the setRadius method using rad as the argument

    • Notice that we can call methods from inside of other methods. This is what we have already been doing inside of the main method, but up to this point, it may not have been obvious that this is what we have been doing.

    • Notice that we can pass parameters from one method as an argument for a parameter in a different method.

  • Inside of the constructor, call your setName method using circleName as an argument

  • Update your Circle class to have a new public method that returns a type of String named getInfo

    • Create a new String variable that you can use to build up the following as a single large string:

<name>:

Radius: <radius>

Diameter: <diameter>

Area: <area>

  • Use System.lineSeparator() to get a string of either or depending on the OS to separate lines in a string

  • Notice that we are making a string to store in a variable, not printing the information out directly to the screen

  • Return your String variable

  • Update your TooManyCirclesTester class, which reused code from part 3, with the following changes:

    • Replace references to the Circles default constructor (no arguments) with the newly created constructor.

      • Use the appropriate arguments as necessary

      • You may use string literals for each circles name

    • Remove any unnecessary calls to set a circles radius, i.e. immediately after a constructor.

    • Replace any print statements that print out a circles information with a single print statement that uses the Circle classes new getInfo method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

Discuss the techniques of job analysis.

Answered: 1 week ago

Question

How do we do subnetting in IPv6?Explain with a suitable example.

Answered: 1 week ago

Question

Explain the guideline for job description.

Answered: 1 week ago

Question

What is job description ? State the uses of job description.

Answered: 1 week ago

Question

What are the objectives of job evaluation ?

Answered: 1 week ago