![]() What should we call this class? What data does it need to keep track of in instance variables? What is the data type for the instance variables? What methods do we need? (You could draw a Class Diagram for this class using or, although it is not required). Riddle Answer: To get to the other slide!įirst, brainstorm in pairs to do the Object-Oriented Design for a riddle asking program. Riddle Question: Why did the chicken cross the playground? In this project, you will create a class that can tell riddles like the following: Take one of the classes you listed, and try to come up with 2 pieces of data in that class that will be the instance variables. Chance and Community Chest cards can change everything.” What classes would you need to create a computer version of this game? (Remember to look for the nouns). Build houses and hotels on your properties and bankrupt your opponents to win it all. For example, here is the description for Monopoly (trademark Hasbro games): “Buy, sell, dream and scheme your way to riches. ![]() Think about what objects are in the game. For an example, try the problem below.ĥ-1-6: Say you wanted to make a computer game from a board game that you are playing. When you are given a problem specification, look for the nouns to identify what classes you need to create. If you want to draw your own, or are good free online drawing tools for UML class diagrams. Here is a tutorial on class diagrams that explains it in more detail if you are curious (Class diagrams are not on the AP CS A exam). The - in front of the attributes indicate that they are private, and the + in front of the methods indicate that they are public. ![]() For example, here is the class diagram for the Turtle class that we have seen before. In Object-Oriented Design (OOD), programmers first decide which classes are needed to solve a problem and then figure out the data and methods in each class. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |