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
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