Explanation of Solution
Given: The network project version and the display method is in the Post class.
To find:
The display method is shifted into the class MessagePost and PhotoPost.
The result on compilation of the program.
Solution:
The program shows compile time error after shifting the display() method from Post class to MessagePost and PhotoPost.
The MessagePost and PhotoPost are the subclasses of Post class. The private members can access only from the member function of the same class. The display() method tries to access the private members of the Post class from the subclasses MessagePost and PhotoPost. Therefore, it shows compile time error. A public member function created in the Post class and calling that from the display method removes error.
It also shows error in NewsFeed class because the NewsFeed class calls the display() method with the object of type Post and the display method is not in the Post class. Hence, it shows compile time error.
Want to see more full solutions like this?
Chapter 11 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- Try removing the return statement from the body of getPrice. What error message do you see now when you try compiling the class?arrow_forwardExamine the getBalance method's header and body, and then evaluate how they stack up against those of the getPrice method. I'm confused as to the differences between the two.arrow_forwardWhat is Toolkit.PostfixNotation? Is this a separate class?arrow_forward
- Write in Java! Write the Widget class. a. A widget has a name and price. b. The default for name should be “widget” c. Write a constructor (not the no-args), all getters and setters. d. Add a toString method. e. Create an object of type Widget.arrow_forwardOpen the clock-display project and create a ClockDisplay object by selecting the following constructor: new ClockDisplay() Call its getTime method to find out the initial time the clock has been set to. Can you work out why it starts at that particular time?arrow_forwardPlease help me create a cave class for a Hunt the Wumpus game (in java). You can read the rules in it's entirety of the Hunt the Wumpus game online to get a better idea of the specifications. It's an actual game. INFORMATION: The object of this game is to find and kill the Wumpus within a minimum number of moves, before you get exhausted or run out of arrows. There is only one way to win: you must discover which room the Wumpus is hiding in and kill it by shooting an arrow into that room from an adjacent room. The Cave The Wumpus lives in a cave of 30 rooms. The rooms are hexagonal. Each room has up to 3 tunnels, allowing access to 1, 2 or 3 (out of 6) adjacent rooms. The attached diagram shows the layout of rooms in the cave. The map wraps around such that rooms on the edges (white cells) have neighbors from the opposite edge (blue cells). E.g., the neighbors of room 1 are rooms 25, 26, 2, 7, 6, and 30, and you could choose to connect room 1 to any of these rooms. Observe how…arrow_forward
- Please help me create a cave class for a Hunt the Wumpus game. You can read the rules in it's entirety of the Hunt the Wumpus game online to get a better idea of the specifications. It's an actual game. INFORMATION: The object of this game is to find and kill the Wumpus within a minimum number of moves, before you get exhausted or run out of arrows. There is only one way to win: you must discover which room the Wumpus is hiding in and kill it by shooting an arrow into that room from an adjacent room. The Cave The Wumpus lives in a cave of 30 rooms. The rooms are hexagonal. Each room has up to 3 tunnels, allowing access to 1, 2 or 3 (out of 6) adjacent rooms. The attached diagram shows the layout of rooms in the cave. The map wraps around such that rooms on the edges (white cells) have neighbors from the opposite edge (blue cells). E.g., the neighbors of room 1 are rooms 25, 26, 2, 7, 6, and 30, and you could choose to connect room 1 to any of these rooms. Observe how room 1…arrow_forwardWrite a new snowflake class that extends AbstractShape. Your snowflake should be a unique and simple shape unlike any other student’s. Use the drawing methods provided in the imported Graphics class The SimpleSnowFlake is provided in the project as an additional reference. Add an equals(Object o) method that will compare unique instance variable data and return true if two of your snowflakes are the same. Your equals method should override the method from the Object class and call the equals method of AbstractShape Your snowflake should be a different color and move in a different and unique way.arrow_forward.If the name of getBalance is changed to getAmount, does the return statement in the body of the method also need to be changed for the code to compile? Try it out within BlueJ. What does this tell you about the name of an accessor method and the name of the field associated with it?arrow_forward
- Take your time with this. Programming language is Java.arrow_forwardLook at the API of the Point class and find out how to construct a Point object. Write a Java program “PointTester”, that constructs two points with coordinates (3, 4) and (–3, –4). Find the distance between them, using the distance method. Print the distance, as well as the expected value. (You may draw a sketch on graph paper to find the value you will expect.) - Update your program so it randomly select coordinate points (x,y), where −50 ≤ ? ≤ 50 ??? ? ∈ [−90, 90].arrow_forwardPlease show work in javaarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education