The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
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. Use BlueJ to create two objects of this class and invoke their sayHello methods.
That is boring—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.6 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 can't do that."
Test your class in BlueJ. Make objects that greet the world and Dave, and invoke methods on them.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on-----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be-----------