Question: Description: The classic HelloWorld program is a simple program used to illustrate the basic syntax of a programming language. In its simplest form, the program

Description:

The classic HelloWorld program is a simple program used to illustrate the basic syntax of a programming language. In its simplest form, the program displays the text Hello, World! to the user. It can serve as a great starting point to explore and learn more complex concepts.

Assignment:

Create a MultiGreeter class with the following capabilities:

Feature

Signature

Requirement

Constructors

MultiGreeter()

No-argument constructor; greeter will have 1 default greeting Hello;

MultiGreeter(int maxGreetings)

Creates a greeter that can hold up to maxGreetings greeting strings. MaxGreetings must be non-negative--it can be 0.

Methods

getMaxGreetings() : int

Returns the maxGreetings, that is, the maximum number of greetings that can be added to this Greeter

getNumGreetings(): int

Returns the actual number of greetings added to this greeter.

addGreeting(String greeting) : boolean

Adds a greeting to this Greeter. If Greeter already has maxGreetings added, the greeting will not be added and the method will return false; otherwise the method will return true.

getGreetings(): String []

Returns an array containing the greeting strings added to this Greeter

greet(String name) : String

Returns a salutation in the form greetingString, name!, where

greetingString is one of the greeting strings added to the Greeter picked at random. If not greetings have been added, the system will use the default greeting "Hello"

name a provided name.

greet() : String

As specified above, however the system will use the default name, World

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!