Skip to content

Instantly share code, notes, and snippets.

View davegotz's full-sized avatar

David Gotz davegotz

View GitHub Profile
@davegotz
davegotz / vehicles_part_2.py
Created April 16, 2019 11:59
Polymorphism Example
__author__ = 'David Gotz, [email protected], Onyen = gotz'
# Define the superclass Vehicle
class Vehicle:
# Define the initialization method
def __init__(self, driver):
self.driver = driver
self.passengers = None
# Load a list of passengers into the vehicle
@davegotz
davegotz / vehicles_part_1.py
Created April 16, 2019 11:59
Inheritance Example
__author__ = 'David Gotz, [email protected], Onyen = gotz'
# Define the superclass Vehicle
class Vehicle:
# Define the initialization method
def __init__(self, driver):
self.driver = driver
self.passengers = None
@davegotz
davegotz / blackjack_oop_part2.py
Last active April 2, 2019 14:50
Added hand implementation and __str__ methods.
import random
# Playing Card class, represents a single playing card.
class PlayingCard:
# Value should be 1-13, with 1 for Ace, 11 for Jack, etc.
def __init__(self, value, suit):
# Setup the instance variables.
self.value = value
self.suit = suit
@davegotz
davegotz / blackjack_oop_day1.py
Created April 2, 2019 14:22
First day with blackjack example
import random
# Playing Card class, represents a single playing card.
class PlayingCard:
# Value should be 1-13, with 1 for Ace, 11 for Jack, etc.
def __init__(self, value, suit):
# Setup the instance variables.
self.value = value
self.suit = suit
# Get a list of names
def get_name_list():
name_list = []
name = input("Enter name #1 (or press enter to stop): ")
# Keep going until the empty string is returned by input.
while name != "":
# Append the most recent name and ask the user for the next name.
name_list.append(name.upper())
name = input("Enter name #"+str(len(name_list)+1)+" (or press enter to stop): ")
import random
# Playing Card class, represents a single playing card.
class PlayingCard:
# Value should be 1-13, with 1 for Ace, 11 for Jack, etc.
def __init__(self, value, suit):
# Setup the instance variables.
self.value = value
self.suit = suit
import random
# Playing Card class, represents a single playing card.
class PlayingCard:
def __init__(self, value, suit):
# Setup the instance variables.
if value == 1:
value = 'Ace'
elif value == 11:
value = 'Jack'
# Playing Card class, represents a single playing card.
class PlayingCard:
def __init__(self, value, suit):
# Setup the instance variables.
self.value = value
self.suit = suit
self.face_up = False
def get_suit(self):
return self.suit
# Playing Card class, represents a single playing card.
class PlayingCard:
def __init__(self, value, suit):
# Setup the instance variables.
self.value = value
self.suit = suit
self.face_up = False
def main():
import random
MAX_NUMBER = 10
def user_picks():
user_numbers = set()
# Add six numbers to the set.
while len(user_numbers) < 6: