Answered step by step
Verified Expert Solution
Question
1 Approved Answer
WRITING METHODS Write a class MyMethods containing the following 2 methods: a method named volume ( ) that accepts 3 integer parameters named width, length,
WRITING METHODS
Write a class MyMethods containing the following methods:
a method named volume that accepts integer parameters named width, length, and
height. The method returns the volume of the rectangular box it represents.
For example, if parameter values are the method returns
a method named avgFaceValues that takes Die objects as parameters Use the Die
class developed in class The method returns the average face value of the two die
objects. For example, if the first parameter is a Die object with face value and
second parameter a Die object with face value the method should return
Write an application, TestMethods, that testsinvokes the methods in problem The
program should instantiate an instance object of the class MyMethods and invoke the
methods with made up parameter data. The application should have at least one invocation of
each method.
WRITING CLASSES
Given the class Point below, define a class Circle that represents a circle with a given center
and radius. The Circle class should have an attribute named center as well as an
integer radius The center is a Point object, defined by the class Point. The class should also
have these members:
the constructor of the class, which should take parameters to initialize all attributes
a getter for each instance data
a setter for each instance data
an equals method that returns true if two circles have same radii and false otherwise
a circumference method that returns the circumference of the circle
a toString method that returns the summary of a Circle object
public class Point
private int ;
public Point int newX, int newY
new ;
new
public String tostring
return x:xy:y;
public double distance Point other
return Math.Sgrt Mathpow xother.xMath.pow y
other.y;
Write an application CircleTest that first creates two Points objects, point with random
coordinates from to inclusive, and point with coordinates The program will then
instantiate two circles with the following radiuscenter requirements:
Radius entered from the keyboard and point as the center
Radius and point as the center
The program prints to the screen:
the summary of each circle
one of these two values:
the distance between their centers if the two circles are "equal" OR
@ the average circumference, otherwise.
For full credit, you MUST use the circle objects and their instance methods when producing the
two values to display.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started