Programming and Problem Solving with Java

(やまだぃちぅ) #1

CASE STUDY


32


coordinating plan is called a driver.In our driver, we write a series of steps that refers to
each object and its responsibility as necessary. For example:

As we will see, Java uses a similar mechanism (known as a method call) for naming an
object and one of its responsibilities in order to get the object to carry out an action.
Many of the statements we write in our Java programs are of this sort. Over the next
few chapters you will gain a great deal of experience with writing and calling methods.
We’ve illustrated the use of problem solving in a noncomputer context to show that
these techniques are very general. Even if your career takes you in a direction that
doesn’t require computer programming, the organizational and problem-solving skills
that you learn in this course can be applied in many different situations. By learning to
program a computer, which requires very precise instructions, you can hone your prob-
lem-solving skills to a much higher degree.

You: Call guests and keep a count of the ones who can come.
Sally: Use count to write shopping list and buy food.
James: Select music.
James: Deliver stereo (collaborate with Sally for delivery).
You: Clean apartment.
You: Move furniture (collaborate with Sally and James on moving heavy pieces).
You: Welcome guests.
Sally: Take care of food.
James: Run stereo.
James: Help lead games.
You: Say goodbye to guests.
You: Clean apartment and move furniture back (collaborate with Sally and James).
James: Return stereo (collaborate with Sally).
Free download pdf