(Solved) : Problem 1 Write Java Class Model Ball Ball Color Radius Established Initially Ball Object Q26268163 . . .

Problem 1:

Write a Java class to model a Ball. A ball has a color andradius (established initially when a ball object is created).Include getter and setter methods, a toString method, an equalsmethod (balls are equal if they have the same radius and color) anda compareTo method (based on radius alone). The Ball class shouldinclude methods to compute (and return) the ball’s circumference,surface area and volume. It should also include a static variableto store a count of the number of Ball objects created. Write atest class to create a few balls and test their methods. Make sureyou print a count of the number of balls created (using the staticvariable).

Problem 2:

Design a Message class to represent an e-mailmessage. A message has a recipient, a sender and message text. Yourclass should have the following methods:

A constructor that accepts the sender and recipient

An append method that appends a line of text tothe message body

A toString method that turns the message into along string such as “From: Luke

Skywalker%nTo: Darth Vader%nText: Are you sure you’re myfather?”

Then design a Mailbox class to store e-mailmessages. This class should support the following methods:

public void addMessage(Message m)

public Message getMessage(int i)

public void removeMessage(int i)

Write a simple menu-driven application to test these classes. Itshould provide these menu options:

New message – prompts the user to enter allmessage information
Delete message – prompts for the message index anddeletes that message View message – prompts forthe message index and then displays the messageList messages – displays all messages
Quit

Note: Each class should be in its own file. All classes shouldbe contained in one BlueJ project.

Expert Answer


1.

public class Ball {

private String colour; . . .