Object Oriented Programming Basics

Object Oriented Programming Basics.

I’m studying for my Python class and don’t understand how to answer this. Can you help me study?

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now

Object Oriented Programming Basics

Reading, June 10, 2020

Logistics

  • Due: Wednesday, June 10th no later than 5pm.
  • Submission instructions: complete the assigned number of activities in each of the assigned subsections of Chapter 17. You do not need to submit anything to Brightspace.
  • Deadline reminder: once this deadline passes, Runestone Interactive will no longer allow you to collect points for completing the activities.

Key ideas

  • Thus far, we have used the procedural paradigm to solve problems. With the procedural paradigm, the focus on solving a problem is on the actions. In Python, these actions are implemented with functions.
  • Python also supports the object-oriented programming paradigm. With the OOP paradigm, the focus on solving a problem is on the objects. An object contains both data (called the state) and functionality (called methods).
  • Example: Consider the turtle module. This module is implemented using object-oriented programming.
  • Example: date.py
  • Functions can take objects as parameters.
  • Functions can return objects.
  • Method __str__ can be used to override how objects are printed, e.g. print(object).
  • It is common to split classes into their own files and import them.

Assignment

Grading – 10 points

  • 10 points – the required number of activities were completed for each subsection before the deadline.

Grading turnaround

This reading assignment will be graded with scores in Brightspace by office hours the following class day.

Optional activities

ACTIVITY 1

Create a class named Pokemon that has the following instance variables: number, name, and combat_points. Add a constructor method that enables a new Pokémon to be created. Add methods named get_name, get_number, get_combat_pointsand set_combat_points. Then, write a program that utilizes the functionality of the Pokemon class in its entirety.

ACTIVITY 2

In the game of Black Jack, an ace is worth 11 points, a king is worth 10 points, a queen is worth 10 points, a jack is worth 10 points, and all other cards are worth face value. Download card.pyand blackjack.py onto your local machine. Complete method assign_value and function process_handsuch that the following output is produced when the program is run.

<code>ace of spades, king of diamonds evaluates to 21_x000D_
_x000D_
queen of hearts, ace of spades evaluates to 21_x000D_
_x000D_
ace of spades, jack of clubs evaluates to 21_x000D_
_x000D_
ten of spades, ace of spades evaluates to 21_x000D_
_x000D_
two of spades, three of clubs, four of diamonds, five of hearts, six of spades, seven of clubs evaluates to 27_x000D_
_x000D_
eight of diamonds, nine of hearts, two of spades evaluates to 19_x000D_
</code>

ACTIVITY 3

Download carddeck.py.

  • Answer the following questions:
    1. What is cards in the program?
    2. What does the Deck constructor do?
  • Uncomment the two commented statements at the bottom and supply the missing shufflemethod.
  • Split the solution into three files: Card.py, Deck.py and carddeck.py.

Object Oriented Programming Basics