Problem

In your network project, add a display method in class Post again. For now, write the me...

In your network project, add a display method in class Post again. For now, write the method body with a single statement that prints out only the username. Then modify the display methods in MessagePost and PhotoPost so that the MessagePost version prints out only the message and the PhotoPost version prints only the caption. This removes the other errors encountered above (we shall come back to those below).

You should now have a situation corresponding to Figure 9.4, with display methods in three classes. Compile your project. (If there are errors, remove them. This design should work.) Before executing, predict which of the display methods will get called if you execute the news feed’s show method.

Try it out. Enter a message post and a photo post into the news feed and call the news feed’s show method. Which display methods were executed? Was your prediction correct? Try to explain your observations.

Figure 9.4

Display, version 3: display method in subclasses and superclass

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 11
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT