diff --git a/lab08/.ok_history b/lab08/.ok_history new file mode 100644 index 0000000..6d3cea1 Binary files /dev/null and b/lab08/.ok_history differ diff --git a/lab08/.ok_storage b/lab08/.ok_storage new file mode 100644 index 0000000..58b6124 Binary files /dev/null and b/lab08/.ok_storage differ diff --git a/lab08/__pycache__/cards.cpython-36.pyc b/lab08/__pycache__/cards.cpython-36.pyc new file mode 100644 index 0000000..32eb675 Binary files /dev/null and b/lab08/__pycache__/cards.cpython-36.pyc differ diff --git a/lab08/__pycache__/classes.cpython-36.pyc b/lab08/__pycache__/classes.cpython-36.pyc new file mode 100644 index 0000000..1029109 Binary files /dev/null and b/lab08/__pycache__/classes.cpython-36.pyc differ diff --git a/lab08/__pycache__/lab08.cpython-36.pyc b/lab08/__pycache__/lab08.cpython-36.pyc new file mode 100644 index 0000000..9e7d904 Binary files /dev/null and b/lab08/__pycache__/lab08.cpython-36.pyc differ diff --git a/lab08/car.py b/lab08/car.py new file mode 100644 index 0000000..33ac606 --- /dev/null +++ b/lab08/car.py @@ -0,0 +1,31 @@ +class Car(object): + num_wheels = 4 + gas = 30 + headlights = 2 + size = 'Tiny' + + def __init__(self, make, model): + self.make = make + self.model = model + self.color = 'No color yet. You need to paint me.' + self.wheels = Car.num_wheels + self.gas = Car.gas + + def paint(self, color): + self.color = color + return self.make + ' ' + self.model + ' is now ' + color + + def drive(self): + if self.wheels < Car.num_wheels or self.gas <= 0: + return 'Cannot drive!' + self.gas -= 10 + return self.make + ' ' + self.model + ' goes vroom!' + + def pop_tire(self): + if self.wheels > 0: + self.wheels -= 1 + + def fill_gas(self): + self.gas += 20 + return 'Gas level: ' + str(self.gas) + diff --git a/lab08/cardgame.py b/lab08/cardgame.py new file mode 100644 index 0000000..998c007 --- /dev/null +++ b/lab08/cardgame.py @@ -0,0 +1,135 @@ +from classes import * +from cards import * + +try: + import readline +except ImportError: + pass + +########### +# Parsing # +########### + +def card_parse(line, handsize): + tokens = line.split() + if not tokens: + raise SyntaxError('No command given') + elif len(tokens) > 1: + raise SyntaxError('Too many inputs') + card_index = tokens.pop(0) + if not card_index.isdigit(): + raise SyntaxError('Wrong type of input') + card_index = int(card_index) + if card_index >= handsize or card_index < 0: + raise SyntaxError('Invalid card number') + return card_index + +def name_parse(line): + if not line: + raise SyntaxError('No command given') + return line + +######## +# REPL # +######## + +def read_eval_print_loop(): + while True: + try: + line = input('What is your name?> ') + name = name_parse(line) + break + except (KeyboardInterrupt, EOFError, SystemExit): # If you ctrl-c or ctrl-d + print('\nSee you next game!') + return + except SyntaxError as e: + print('ERROR:', e) + p1 = Player(player_deck, name) + p2 = Player(opponent_deck, 'Opponent') + print(WELCOME_MESSAGE) + duel = Game(p1, p2) + draw = True + while True: + if duel.game_won() == 1: + print(WIN_MESSAGE) + return + elif duel.game_won() == 2: + print(LOSE_MESSAGE) + return + print() + try: + if draw: + p1.draw() + p2.draw() + else: + draw = True + p1.display_hand() + print('Please enter the number next to the card you would like to play this round.') + line = input('card> ') + card_index = card_parse(line, len(p1.hand)) + duel.play_round(p1.play(card_index), p2.play_random()) + duel.display_scores() + except (KeyboardInterrupt, EOFError, SystemExit): # If you ctrl-c or ctrl-d + print('\nGood game. Bye!') + return + except AssertionError: # Deck out + if p1.deck.is_empty() and p2.deck.is_empty(): + print(TIE_MESSAGE) + return + elif p1.deck.is_empty(): + print(PLAYER_DECKOUT_MESSAGE) + return + else: + print(OPPONENT_DECKOUT_MESSAGE) + return + except SyntaxError as e: + print('ERROR:', e) + draw = False + +################# +# Configuration # +################# + +WELCOME_MESSAGE = """ +Welcome to Magic: The Lambda-ing! + +Your code has taken on a mind of its own and has +challenged you to a game of cards! If you need a refresher +on the rules, check out the section on the lab page. + +Let's get this duel started, shall we? +""" + +WIN_MESSAGE = """ +You have vanquished your foe in a duel! + +Congratulations! You won this game of Magic: The Lambda-ing! +""" + +LOSE_MESSAGE = """ +You have been defeated by your foe in a duel! + +I'm sorry, you lost this game of Magic: The Lambda-ing. +""" + +TIE_MESSAGE = """ +You and your opponent have no cards left in your decks! + +You tied this game of Magic: The Lambda-ing. Who will win if you play again? +""" + +PLAYER_DECKOUT_MESSAGE = """ +You have no cards left in your deck! + +I'm sorry, you lost this game of Magic: The Lambda-ing. +""" + +OPPONENT_DECKOUT_MESSAGE = """ +Your opponent has no cards left in their deck! + +Congratulations! You won this game of Magic: The Lambda-ing! +""" + +if __name__ == '__main__': + read_eval_print_loop() + diff --git a/lab08/cards.py b/lab08/cards.py new file mode 100644 index 0000000..cdbddfb --- /dev/null +++ b/lab08/cards.py @@ -0,0 +1,65 @@ +# All cards available in a standard deck. +from classes import * + +#TAs +aaron = TACard('Baron Aaron', 2100, 1300) +addison = TACard('Addison, from operator import add', 1000, 2000) +albert = TACard('Albert, Lethargy Incarnate', 1000, 2000) +alex_k = TACard('Alex, Skipper of Labs and Preparer for Exams', 2293.141593, 1111.11111) +alex_s = TACard('President Lieutenant Stennet for Senate', 1400, 2000) +aman = TACard('Aman', 1000, 2100) +amrita = TACard('Amrita, the Pun-stoppable', 1800, 1450) +annie = TACard('Annie, the Annihilator of Water', 1700, 1500) +audrey = TACard('Audrey, Excitable Engineer', 1777, 1777) +brandon = TACard('Brandon, Not Brendan ', 1234, 1234) +catherine = TACard('Catherine, Referencer of Self', 2500, 900) +cesar = TACard('Cesar, Surveyor of Steaz', 1337, 2222) +chae = TACard('Chae', 1500, 1900) +charles = TACard('Charles, Protector of UwU', 1000, 2000) +dalton = TACard('Dalton, Unit of Atomic Mass', 2144, 1998) +danelle = TACard('Danelle Nachos', 2200, 1100) +derek = TACard('Derek, The Wan and Only', 2000, 1000) +derrick = TACard('EZ4ENCE', 1100, 2000) +griffin = TACard('Griffin, He Who is Hydrated', 1000, 2000) +jack = TACard('Jack, The Master of Dice', 1650, 2100) +jade = TACard('Jade, Singher of Songs', 1700, 1500) +kavi = TACard('Kavi Gupta', 2100, 1000) +lillian = TACard('Lillian, Linda', 1100, 2100) +nancy = TACard('Nancy, The Sheep in the Jeep', 1100, 2100) +patricia = TACard('Patricia, Pokémon Master', 1800, 1600) +paul = TACard('Better Call Paul', 2100, 1200) +regina = TACard('Regina, Wrangler of Skipped Readings', 1200, 2250) +richard = TACard('Richard, Admirer of Baby Yoda ', 1800, 2000) +sean = TACard('Sean, the Over-Caffeinated', 1000, 2300) +shayna = TACard('Shayna, Procrastinator Supreme', 1916, 1459) +yannan = TACard('Yannan, the Yammeister', 1500, 1900) +yichen = TACard('Yichen, Drinker of Boba', 1800, 1500) + +#Tutors +christine = TutorCard('Christine', 1500, 1700) +ethan = TutorCard('Ethan, Pillar of the Demon Slayer Corps', 1800 , 1100) +grant = TutorCard('Grant', 1100, 2100) +ivan = TutorCard('Ivan, the ender of dreaming the starter of scheming', 1900, 2300) +jason = TutorCard('Jason, Counter of Chang-e', 1500, 1900) +jemmy = TutorCard('Jemmy, the Joker', 1200, 1700) +jessica = TutorCard('Jessica, Lover of Shin Ramen', 1528, 2154) +lauren = TutorCard('Lauren, Queen of First Floor Moffitt', 1200, 1800) +matthew = TutorCard('Matty Lee', 2000, 1500) +nicholas = TutorCard('Nicholas, Keeper of Shared Secrets', 1009, 2297) +nikhita = TutorCard('Nikhita, Always Schemin', 1700, 1700) +uma = TutorCard('Uma, Hoarder of Hydroflasks', 1200, 1700) + + + + +# Professors +denero = ProfessorCard('John DeNero, Protector of Abstraction Barriers', 5000, 5000) + +# A standard deck contains all standard cards. +standard_cards = [denero, aaron, addison ,albert ,alex_k ,alex_s ,aman ,amrita ,annie ,audrey ,brandon ,catherine ,cesar ,chae ,charles ,dalton ,danelle ,derek ,derrick ,griffin ,jack ,jade ,kavi ,lillian ,nancy ,patricia ,paul ,regina ,richard ,sean ,shayna ,yannan ,yichen ,ethan ,grant ,ivan ,jason ,jemmy ,jessica ,lauren ,matthew ,nicholas ,nikhita ,uma] +standard_deck = Deck(standard_cards) + +# The player and opponent's decks are the standard deck by default. +player_deck = standard_deck.copy() +opponent_deck = standard_deck.copy() + diff --git a/lab08/classes.py b/lab08/classes.py new file mode 100644 index 0000000..b5104fc --- /dev/null +++ b/lab08/classes.py @@ -0,0 +1,325 @@ +# Magic the Lambda-ing! + +import random + +class Card: + cardtype = 'Staff' + + def __init__(self, name, attack, defense): + """ + Create a Card object with a name, attack, + and defense. + >>> staff_member = Card('staff', 400, 300) + >>> staff_member.name + 'staff' + >>> staff_member.attack + 400 + >>> staff_member.defense + 300 + >>> other_staff = Card('other', 300, 500) + >>> other_staff.attack + 300 + >>> other_staff.defense + 500 + """ + "*** YOUR CODE HERE ***" + self.name = name + self.attack = attack + self.defense = defense + + def power(self, other_card): + """ + Calculate power as: + (player card's attack) - (opponent card's defense)/2 + where other_card is the opponent's card. + >>> staff_member = Card('staff', 400, 300) + >>> other_staff = Card('other', 300, 500) + >>> staff_member.power(other_staff) + 150.0 + >>> other_staff.power(staff_member) + 150.0 + >>> third_card = Card('third', 200, 400) + >>> staff_member.power(third_card) + 200.0 + >>> third_card.power(staff_member) + 50.0 + """ + "*** YOUR CODE HERE ***" + return self.attack - other_card.defense/2 + + + def effect(self, other_card, player, opponent): + """ + Cards have no default effect. + """ + return + + def __repr__(self): + """ + Returns a string which is a readable version of + a card, in the form: + : , [, ] + """ + return '{}: {}, [{}, {}]'.format(self.name, self.cardtype, self.attack, self.defense) + + def copy(self): + """ + Returns a copy of this card. + """ + return Card(self.name, self.attack, self.defense) + +class Player: + def __init__(self, deck, name): + """Initialize a Player object. + A Player starts the game by drawing 5 cards from their deck. Each turn, + a Player draws another card from the deck and chooses one to play. + >>> test_card = Card('test', 100, 100) + >>> test_deck = Deck([test_card.copy() for _ in range(6)]) + >>> test_player = Player(test_deck, 'tester') + >>> len(test_deck.cards) + 1 + >>> len(test_player.hand) + 5 + """ + self.deck = deck + self.name = name + "*** YOUR CODE HERE ***" + self.hand = [] + for i in range(5): + self.draw() + + def draw(self): + """Draw a card from the player's deck and add it to their hand. + >>> test_card = Card('test', 100, 100) + >>> test_deck = Deck([test_card.copy() for _ in range(6)]) + >>> test_player = Player(test_deck, 'tester') + >>> test_player.draw() + >>> len(test_deck.cards) + 0 + >>> len(test_player.hand) + 6 + """ + assert not self.deck.is_empty(), 'Deck is empty!' + "*** YOUR CODE HERE ***" + self.hand.append(self.deck.draw()) + + def play(self, card_index): + """Remove and return a card from the player's hand at the given index. + >>> from cards import * + >>> test_player = Player(standard_deck, 'tester') + >>> ta1, ta2 = TACard("ta_1", 300, 400), TACard("ta_2", 500, 600) + >>> tutor1, tutor2 = TutorCard("t1", 200, 500), TutorCard("t2", 600, 400) + >>> test_player.hand = [ta1, ta2, tutor1, tutor2] + >>> test_player.play(0) is ta1 + True + >>> test_player.play(2) is tutor2 + True + >>> len(test_player.hand) + 2 + """ + "*** YOUR CODE HERE ***" + return self.hand.pop(card_index) + + def display_hand(self): + """ + Display the player's current hand to the user. + """ + print('Your hand:') + for card_index, displayed_card in zip(range(len(self.hand)),[str(card) for card in self.hand]): + indent = ' '*(5 - len(str(card_index))) + print(card_index, indent + displayed_card) + + def play_random(self): + """ + Play a random card from hand. + """ + return self.play(random.randrange(len(self.hand))) + +###################### +# Optional Questions # +###################### + +class TutorCard(Card): + cardtype = 'Tutor' + + def effect(self, other_card, player, opponent): + """ + Discard the first 3 cards in the opponent's hand and have + them draw the same number of cards from their deck. + >>> from cards import * + >>> player1, player2 = Player(player_deck, 'p1'), Player(opponent_deck, 'p2') + >>> other_card = Card('other', 500, 500) + >>> tutor_test = TutorCard('Tutor', 500, 500) + >>> initial_deck_length = len(player2.deck.cards) + >>> tutor_test.effect(other_card, player1, player2) + p2 discarded and re-drew 3 cards! + >>> len(player2.hand) + 5 + >>> len(player2.deck.cards) == initial_deck_length - 3 + True + """ + "*** YOUR CODE HERE ***" + for i in range(3): + opponent.hand.pop(0) + for i in range(3): + opponent.draw() + #Uncomment the line below when you've finished implementing this method! + print('{} discarded and re-drew 3 cards!'.format(opponent.name)) + + def copy(self): + """ + Create a copy of this card. + """ + return TutorCard(self.name, self.attack, self.defense) + +class TACard(Card): + cardtype = 'TA' + + def effect(self, other_card, player, opponent): + """ + Swap the attack and defense of an opponent's card. + >>> from cards import * + >>> player1, player2 = Player(player_deck, 'p1'), Player(opponent_deck, 'p2') + >>> other_card = Card('other', 300, 600) + >>> ta_test = TACard('TA', 500, 500) + >>> ta_test.effect(other_card, player1, player2) + >>> other_card.attack + 600 + >>> other_card.defense + 300 + """ + "*** YOUR CODE HERE ***" + other_card.attack, other_card.defense = other_card.defense, other_card.attack + + def copy(self): + """ + Create a copy of this card. + """ + return TACard(self.name, self.attack, self.defense) + +class ProfessorCard(Card): + cardtype = 'Professor' + + def effect(self, other_card, player, opponent): + """ + Adds the attack and defense of the opponent's card to + all cards in the player's deck, then removes all cards + in the opponent's deck that share an attack or defense + stat with the opponent's card. + >>> test_card = Card('card', 300, 300) + >>> professor_test = ProfessorCard('Professor', 500, 500) + >>> opponent_card = test_card.copy() + >>> test_deck = Deck([test_card.copy() for _ in range(8)]) + >>> player1, player2 = Player(test_deck.copy(), 'p1'), Player(test_deck.copy(), 'p2') + >>> professor_test.effect(opponent_card, player1, player2) + 3 cards were discarded from p2's deck! + >>> [(card.attack, card.defense) for card in player1.deck.cards] + [(600, 600), (600, 600), (600, 600)] + >>> len(player2.deck.cards) + 0 + """ + orig_opponent_deck_length = len(opponent.deck.cards) + "*** YOUR CODE HERE ***" + for card in player.deck.cards: + card.attack += other_card.attack + card.defense += other_card.defense + left_cards = [] + for card in opponent.deck.cards: + if card.defense != other_card.defense or card.attack != other_card.attack: + left_cards.append(card) + opponent.deck.cards = left_cards + discarded = orig_opponent_deck_length - len(opponent.deck.cards) + if discarded: + #Uncomment the line below when you've finished implementing this method! + print('{} cards were discarded from {}\'s deck!'.format(discarded, opponent.name)) + return + + def copy(self): + return ProfessorCard(self.name, self.attack, self.defense) + + +######################################## +# Do not edit anything below this line # +######################################## + +class Deck: + def __init__(self, cards): + """ + With a list of cards as input, create a deck. + This deck should keep track of the cards it contains, and + we should be able to draw from the deck, taking a random + card out of it. + """ + self.cards = cards + + def draw(self): + """ + Draw a random card and remove it from the deck. + """ + assert self.cards, 'The deck is empty!' + rand_index = random.randrange(len(self.cards)) + return self.cards.pop(rand_index) + + def is_empty(self): + return len(self.cards) == 0 + + def copy(self): + """ + Create a copy of this deck. + """ + return Deck([card.copy() for card in self.cards]) + +class Game: + + win_score = 8 + + def __init__(self, player1, player2): + """ + Initialize a game of . + """ + self.player1, self.player2 = player1, player2 + self.p1_score = 0 + self.p2_score = 0 + + def play_round(self, p1_card, p2_card): + """ + After each player picks a card, play them against + each other. + """ + p1_card.effect(p2_card, self.player1, self.player2) + p2_card.effect(p1_card, self.player2, self.player1) + p1_power = p1_card.power(p2_card) + p2_power = p2_card.power(p1_card) + if p1_power > p2_power: + # Player 1 wins the round. + self.p1_score += 1 + result = 'won' + elif p2_power > p1_power: + # Player 2 wins the round. + self.p2_score += 1 + result = 'lost' + else: + # This round is a draw. + result = 'tied' + # Display results to user. + print('You {} this round!'.format(result)) + print('{}\'s card: {}; Power: {}'.format(self.player1.name, p1_card, p1_power)) + print('Opponent\'s card: {}; Power: {}'.format(p2_card, p2_power)) + + + def game_won(self): + """ + Check if the game is won and, if so, + which player won. + """ + if self.p1_score < self.win_score and self.p2_score < self.win_score: + return 0 + return 1 if self.p1_score > self.p2_score else 2 + + def display_scores(self): + """ + Display players' scores to the user. + """ + print('{}\'s score: {}'.format(self.player1.name, self.p1_score)) + print('Opponent\'s score: {}'.format(self.p2_score)) + diff --git a/lab08/lab08.ok b/lab08/lab08.ok new file mode 100644 index 0000000..55a83fb --- /dev/null +++ b/lab08/lab08.ok @@ -0,0 +1,31 @@ +{ + "name": "Lab 8", + "endpoint": "cal/cs61a/su20/lab08", + "src": [ + "lab08.py", + "classes.py" + ], + "tests": { + "lab*.py": "doctest", + "tests/*.py": "ok_test", + "classes.py": "doctest" + }, + "default_tests": [ + "iterators", + "make_generators_generator", + "wwpd-car", + "Card.__init__", + "Card.power", + "Player.__init__", + "Player.draw", + "Player.play" + ], + "protocols": [ + "restore", + "file_contents", + "unlock", + "grading", + "analytics", + "backup" + ] +} \ No newline at end of file diff --git a/lab08/lab08.py b/lab08/lab08.py new file mode 100644 index 0000000..5e3617e --- /dev/null +++ b/lab08/lab08.py @@ -0,0 +1,43 @@ +def make_generators_generator(g): + """Generates all the "sub"-generators of the generator returned by + the generator function g. + + >>> def every_m_ints_to(n, m): + ... i = 0 + ... while (i <= n): + ... yield i + ... i += m + ... + >>> def every_3_ints_to_10(): + ... for item in every_m_ints_to(10, 3): + ... yield item + ... + >>> for gen in make_generators_generator(every_3_ints_to_10): + ... print("Next Generator:") + ... for item in gen: + ... print(item) + ... + Next Generator: + 0 + Next Generator: + 0 + 3 + Next Generator: + 0 + 3 + 6 + Next Generator: + 0 + 3 + 6 + 9 + """ + "*** YOUR CODE HERE ***" + def gen_helper(lst): + for x in lst: + yield x + ans = [] + gg = g() + for x in gg: + ans.append(x) + yield gen_helper(ans.copy()) diff --git a/lab08/ok b/lab08/ok new file mode 100644 index 0000000..cbe08ba Binary files /dev/null and b/lab08/ok differ diff --git a/lab08/tests/__init__.py b/lab08/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lab08/tests/__pycache__/__init__.cpython-36.pyc b/lab08/tests/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..c0a278c Binary files /dev/null and b/lab08/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/lab08/tests/__pycache__/iterators.cpython-36.pyc b/lab08/tests/__pycache__/iterators.cpython-36.pyc new file mode 100644 index 0000000..4eb7b09 Binary files /dev/null and b/lab08/tests/__pycache__/iterators.cpython-36.pyc differ diff --git a/lab08/tests/__pycache__/wwpd-car.cpython-36.pyc b/lab08/tests/__pycache__/wwpd-car.cpython-36.pyc new file mode 100644 index 0000000..80b3747 Binary files /dev/null and b/lab08/tests/__pycache__/wwpd-car.cpython-36.pyc differ diff --git a/lab08/tests/iterators.py b/lab08/tests/iterators.py new file mode 100644 index 0000000..b6274f5 --- /dev/null +++ b/lab08/tests/iterators.py @@ -0,0 +1,82 @@ +test = { + 'name': 'Iterators', + 'points': 0, + 'suites': [ + { + 'cases': [ + { + 'code': r""" + >>> s = [1, 2, 3, 4] + >>> t = iter(s) + >>> next(s) + Error + >>> next(t) + 1 + >>> next(t) + 2 + >>> iter(s) + Iterator + >>> next(iter(s)) + 1 + >>> next(iter(t)) + 3 + >>> next(iter(s)) + 1 + >>> next(iter(t)) + 4 + >>> next(t) + StopIteration + """, + 'hidden': False, + 'locked': False + }, + { + 'code': r""" + >>> r = range(6) + >>> r_iter = iter(r) + >>> next(r_iter) + 0 + >>> [x + 1 for x in r] + [1, 2, 3, 4, 5, 6] + >>> [x + 1 for x in r_iter] + [2, 3, 4, 5, 6] + >>> next(r_iter) + StopIteration + >>> list(range(-2, 4)) # Converts an iterable into a list + [-2, -1, 0, 1, 2, 3] + """, + 'hidden': False, + 'locked': False + }, + { + 'code': r""" + >>> map_iter = map(lambda x : x + 10, range(5)) + >>> next(map_iter) + 10 + >>> next(map_iter) + 11 + >>> list(map_iter) + [12, 13, 14] + >>> for e in filter(lambda x : x % 2 == 0, range(1000, 1008)): + ... print(e) + 1000 + 1002 + 1004 + 1006 + >>> [x + y for x, y in zip([1, 2, 3], [4, 5, 6])] + [5, 7, 9] + >>> for e in zip([10, 9, 8], range(3)): + ... print(tuple(map(lambda x: x + 2, e))) + (12, 2) + (11, 3) + (10, 4) + """, + 'hidden': False, + 'locked': False + } + ], + 'scored': False, + 'type': 'wwpp' + } + ] +} diff --git a/lab08/tests/wwpd-car.py b/lab08/tests/wwpd-car.py new file mode 100644 index 0000000..1acde22 --- /dev/null +++ b/lab08/tests/wwpd-car.py @@ -0,0 +1,70 @@ +test = { + 'name': 'Car', + 'points': 0, + 'suites': [ + { + 'cases': [ + { + 'code': r""" + >>> from car import * + >>> deneros_car = Car('Tesla', 'Model S') + >>> deneros_car.model + 'Model S' + >>> deneros_car.gas = 10 + >>> deneros_car.drive() + 'Tesla Model S goes vroom!' + >>> deneros_car.drive() + 'Cannot drive!' + >>> deneros_car.fill_gas() + 'Gas level: 20' + >>> deneros_car.gas + 20 + >>> Car.gas + 30 + """, + 'hidden': False, + 'locked': False + }, + { + 'code': r""" + >>> from car import * + >>> deneros_car = Car('Tesla', 'Model S') + >>> deneros_car.wheels = 2 + >>> deneros_car.wheels + 2 + >>> Car.num_wheels + 4 + >>> deneros_car.drive() # Type Error if an error occurs and Nothing if nothing is displayed + 'Cannot drive!' + >>> Car.drive() # Type Error if an error occurs and Nothing if nothing is displayed + Error + >>> Car.drive(deneros_car) # Type Error if an error occurs and Nothing if nothing is displayed + 'Cannot drive!' + """, + 'hidden': False, + 'locked': False + }, + { + 'code': r""" + >>> from car import * + >>> deneros_car = MonsterTruck('Monster', 'Batmobile') + >>> deneros_car.drive() # Type Error if an error occurs and Nothing if nothing is displayed + Vroom! This Monster Truck is huge! + 'Monster Batmobile goes vroom!' + >>> Car.drive(deneros_car) # Type Error if an error occurs and Nothing if nothing is displayed + 'Monster Batmobile goes vroom!' + >>> MonsterTruck.drive(deneros_car) # Type Error if an error occurs and Nothing if nothing is displayed + Vroom! This Monster Truck is huge! + 'Monster Batmobile goes vroom!' + >>> Car.rev(deneros_car) # Type Error if an error occurs and Nothing if nothing is displayed + Error + """, + 'hidden': False, + 'locked': False + } + ], + 'scored': False, + 'type': 'wwpp' + } + ] +}