Beispiel #1
0
 def setUpClass(self):
     self.red_bag = Lootbag('red')
     self.Amy = Kid('Amy', 1)
     self.Bruce = Kid('Bruce', 0)
     self.red_bag.kids.add(self.Amy)
     self.red_bag.kids.add(self.Bruce)
     self.Amy.add_toy('bike')
     self.Amy.add_toy('ball')
     self.Amy.add_toy('calculator')
Beispiel #2
0
    def make_kids(self):
        kids = []
        for n in range(global_params.num_kids_per_family):
            new_kid = Kid(ineligible_names=self.kid_names)
            self.kid_names[new_kid.sex].append(new_kid.name)
            kids.append(new_kid)

        return kids
Beispiel #3
0
        """Returns the list of deliveries by child"""
        print("----- Delivery List -----")
        for k in self.kids:
            if k.is_nice == True and k.toys and k.delivered == False:
                print(k.toy_list())
            if k.is_nice == False and k.delivered == False:
                print(f"*** {k.name}'s Toy List ***")
                print('Coal')

    def __str__(self):
        return f"This bag is colored {self.color}."


if __name__ == '__main__':
    Blue_Bag = Lootbag('blue')
    Amy = Kid('amy', 1)
    Bruce = Kid('bruce', 0)
    Blue_Bag.kids.add(Amy)
    Blue_Bag.kids.add(Bruce)
    Amy.add_toy('bike')
    Amy.add_toy('sailboat')
    Amy.add_toy('ball')

    print(Blue_Bag)
    Blue_Bag.kid_list()
    Blue_Bag.delivery_list()
    Amy.deliver_all_toys()
    Bruce.deliver_all_toys()
    Amy.deliver_all_toys()
    Bruce.deliver_all_toys()
import sys
from lootbag import Lootbag
from kid import Kid

Yellow_Bag = Lootbag('yellow')
Candace = Kid('candace', 1)
Derek = Kid('derek', 0)
Yellow_Bag.kids.add(Candace)
Yellow_Bag.kids.add(Derek)
Candace.add_toy('crayons')

# Requirements
# 1. Add a toy: (3 args): the word "add", the name of the gift, the name of the child (lootbag.py add kite suzy)
# remove suzy kite
# list children currently receiving presents (using the ls command)
# list all toys for a specific child (ls suzy)
# mark all of a child's toys delivered (delivered suzy)

if len(sys.argv) > 1 and sys.argv[1] == "add":
    # add kite suzy
    # !This looks like it works, but it doesn't. Can't figure out why. It says the toy is added to the list, but printing the list shows that it isn't added. Unit testing shows that the toy DOES get added so IDFK.
    for k in Yellow_Bag.kids:
        if (sys.argv[3]).capitalize() == k.name:
            k.add_toy(sys.argv[2])
            k.toy_list()
elif len(sys.argv) > 1 and sys.argv[1] == "remove":
    # remove suzy kite
    # !Because the add command doesn't work, this one doesn't work. You can't remove a toy if it isn't in there in the first place.
    for k in Yellow_Bag.kids:
        if (sys.argv[2]) == k.name:
            k.remove_toy(sys.argv[3])
Beispiel #5
0
from man import Man
from boy import Boy
from kid import Kid


def atThePark(man):
    print("In the park")
    man.play()


man = Man()
boy = Boy()
kid = Kid()
boy.play()
boy.walk()
boy.eat()
kid.play()
atThePark(man)
atThePark(kid)
atThePark(boy)