It is best to use a POGIL approach with the following. In POGIL students work in groups on activities and each member has an assigned role. For more information see https://cspogil.org/Home.
If you work in a group, have only one member of the group fill in the answers on this page. That person will be able to share answers with the group at the bottom of the page.
Object-oriented programs typically have many classes. Each class describes the data (attributes) that objects of that class have and their behaviors (methods). One class can use objects from another class.
Letβs use the Point class that we created earlier to define a Rectangle class. A rectangle can be defined by two points if we assume that one point is the top left and the other is the bottom right. That means the width of a rectangle is the difference between the x values and the height is the difference between the y values. The area of a rectangle is the width times the height.
Subsection19.10.2Object-Oriented Analysis and Design
How do you determine the classes that you need and the attributes and methods that objects of the class should have? In object-oriented analysis and design you often walk through a scenario of how the system will work. Write down all the nouns and verbs that are mentioned. Nouns are potential classes or attributes. Verbs are potential methods. If a noun represents simple data like a number or string it is usually just an attribute of a class. If a noun has data associated with it or behavior then it is likely a class.
One approach to object-oriented analysis and design is to use index cards to represent classes. Write the class name at the top of the card. Put the data or attributes that each object needs to keep track of below that and the methods or behaviors that objects need to be able to do below that.
When the game starts all of the cards are all face down in rows and columns. You click on a card to select it and it turns over to show the suit and rank (value). Then you click another card to select it and it also turns face up. If the two cards match (have the same rank and value) then the cards stay facing up. Otherwise they both turn down and you take another turn. You win when you have found all of the matches. The game keeps track of the total time it took you to find all of the matches.
In UML each class is shown in a box with the class name on top optionally followed by a line then the attributes and then optionally followed by a line and then the behaviors (methods).
Notice that we have defined a list of suit_names and rank_names in the Card class. These will be created in the class Card and not in each object of the class Card. They are called class attributes. Each object of the Card class doesnβt need to have its own copy of these lists. That would be a waste of space. Instead they are created in the class and all objects of the class have access to it.
Given the Airport class shown below and the class diagram shown above, write the Flight class with an __init__ method that takes the object attributes in order from top to bottom in the class diagram (number, departure_date, departure_time, departure_airport, and arrival_airport).
Given the Item and Order classes shown below, write the get_total method in the Order class that returns a total of all of the prices of the items in the order.
If you worked in a group, you can copy the answers from this page to the other group members. Select the group members below and click the button to share the answers.
The Submit Group button will submit the answer for each each question on this page for each member of your group. It also logs you as the official group submitter.