Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this project, you will explore an object-oriented alternative to the Hello, World program in Chapter 1. Begin with a simple Greeter class that has

In this project, you will explore an object-oriented alternative to the Hello, World program in Chapter 1. Begin with a simple Greeter class that has a single method, sayHello. That method should return a string, not print it. Create two objects of this class and invoke their sayHello methods. Of course, both objects return the same answer. Enhance the Greeter class so that each object produces a customized greeting. For example, the object constructed as new Greeter("Dave") should say "Hello, Dave". (Use the concat method to combine strings to form a longer string, or peek ahead at Section 4.5 to see how you can use the + operator for the same purpose.) Add a method sayGoodbye to the Greeter class. Finally, add a method refuseHelp to the Greeter class. It should return a string such as "I am sorry, Dave. I am afraid I cant do that." If you use BlueJ, place two Greeter objects on the workbench (one that greets the world and one that greets Dave) and invoke methods on them. Otherwise, write a tester program that constructs these objects, invokes methods, and prints the results.

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

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

Azure Analytics is a suite made up of which three tools?

Answered: 1 week ago