コード例 #1
0
 def test_delivered_default(self):
     data = {"parents": ["Alice", "Bob"], "delivered": "October 1st, 2015"}
     self._set_data(data)
     b = Baby(self.url)
     out = b._announce()
     expected = ''
     self.assertEqual(out, expected)
コード例 #2
0
 def test_announce_due_date(self):
     data = {"parents": ["Alice", "Bob"], "due_date": "January 1st, 2015"}
     self._set_data(data)
     b = Baby(self.url)
     out = b._announce()
     expected = 'Alice and Bob are excited to announce ' \
                'the impending arrival of a baby, due on January 1st, 2015'
     self.assertEqual(out, expected)
コード例 #3
0
 def test_announce_name(self):
     data = {"parents": ["Alice", "Bob"], "name": "Claire"}
     self._set_data(data)
     b = Baby(self.url)
     out = b._announce()
     expected = 'Alice and Bob are excited to announce ' \
                'the impending arrival of a baby, Claire'
     self.assertEqual(out, expected)
コード例 #4
0
ファイル: test_baby.py プロジェクト: SwampDragons/baby
 def test_announce_default(self):
     data = {"parents": ["Alice", "Bob"]}
     self._set_data(data)
     b = Baby(self.url)
     out = b._announce()
     expected = 'Alice and Bob are excited to announce ' \
                'the impending arrival of a baby'
     self.assertEqual(out, expected)
コード例 #5
0
ファイル: test_baby.py プロジェクト: SwampDragons/baby
 def test_delivered_default(self):
     data = {"parents": ["Alice", "Bob"],
             "delivered": "October 1st, 2015"}
     self._set_data(data)
     b = Baby(self.url)
     out = b._announce()
     expected = ''
     self.assertEqual(out, expected)
コード例 #6
0
ファイル: test_baby.py プロジェクト: SwampDragons/baby
 def test_announce_due_date(self):
     data = {"parents": ["Alice", "Bob"],
             "due_date": "January 1st, 2015"}
     self._set_data(data)
     b = Baby(self.url)
     out = b._announce()
     expected = 'Alice and Bob are excited to announce ' \
                'the impending arrival of a baby, due on January 1st, 2015'
     self.assertEqual(out, expected)
コード例 #7
0
 def test_gurgle(self):
     data = {"parents": ["Alice", "Bob"]}
     self._set_data(data)
     b = Baby(self.url)
     out = b._gurgle()
     self.assertEqual(out, "gooo gooo")
コード例 #8
0
 def test_cry(self):
     data = {"parents": ["Alice", "Bob"]}
     self._set_data(data)
     b = Baby(self.url)
     out = b._cry()
     self.assertEqual(out, "waaaaaaaaaaah")
コード例 #9
0
from party_wagon import Party_Wagon
from mustang import Mustang
from tesla import Tesla
"""
X- Define 5 of your favorite vehicles
X- Move all common properties in your vehicles to a new Vehicle class.
X- Create an instance of each vehicle.
X- Define a different value for each vehicle's properties.
X- Create a drive() method in the Vehicle class.
X- Override the drive() method in all the other vehicle classes. Include the vehicle's color in the message (i.e. "The blue Ram drives past. RRrrrrrummbbble!").
X- Create a turn(self, direction) method, and a stop(self) method on Vehicle. Define a basic implementation of each.
- Override all three of those methods on some of the vehicles. For example, the stop() method for a plane would be to output the message "The white Cessna rolls to a stop after rolling a mile down the runway."
- Make your vehicle instances perform all three behaviors.
"""

deans_car = Baby("black", 6, "gasoline", "Chevy", "Impala",
                 "Weapons depot in trunk.")

wayne_tech = Batmobile("black", 2, "gasoline", "Chevy", "Batmobile",
                       "All of them.")

who_you_gonna_call = Ecto1("white", 4, "gasoline", "Futura Duplex", "Cadillac",
                           "Gunner seat, y'all!")

turtle_power = Party_Wagon("yellow", 8, "gasoline", "Volkswagen", "Bus",
                           "Pizza launcher.")

mustang_sally = Mustang("cherry red", 5, "gasoline", "Ford", "Mustang", 1965)

starman = Tesla("red", 5, "electricity", "Tesla", "Roadster",
                "It's in friggin' space!")
コード例 #10
0
ファイル: love.py プロジェクト: rockie-yang/baby_generator
 def join(self, papa, on="good_genes", how="inner"):
     # genes_pairs = mama.genes.zip
     return Baby(mama.genes)
コード例 #11
0
ファイル: main.py プロジェクト: nss-cohort-36/Inheritance
# inheritance

# Class based inheritance lets you specify that one type will contain all of the properties and methods that are defined in another type, without having to duplicate the code in the two source code files.

# the parent class is called super class or base class and the child class is called subclass or derived class.

# Overriding methods
# To override a method in the base class, sub class needs to define a method of same signature. (i.e same method name and same number of parameters as method in base class).

from baby import Baby
from cat import Cat

human_baby = Baby("green", "brown", "weird")

cat_baby = Cat("Grey", "brown", "normal")

human_baby.about_me()

cat_baby.about_me()
コード例 #12
0
 def __init__(self, eyeColor, hairColor, toes):
     Baby.__init__(self, eyeColor, hairColor, toes)
     self.type = "cat"
コード例 #13
0
ファイル: test_baby.py プロジェクト: SwampDragons/baby
 def test_gurgle(self):
     data = {"parents": ["Alice", "Bob"]}
     self._set_data(data)
     b = Baby(self.url)
     out = b._gurgle()
     self.assertEqual(out, "gooo gooo")
コード例 #14
0
ファイル: test_baby.py プロジェクト: SwampDragons/baby
 def test_cry(self):
     data = {"parents": ["Alice", "Bob"]}
     self._set_data(data)
     b = Baby(self.url)
     out = b._cry()
     self.assertEqual(out, "waaaaaaaaaaah")
コード例 #15
0
ファイル: life.py プロジェクト: suntyneu/test
def main():
    b = Baby(10000, 100, 90,
             90)  # def __init__(self, money, nice, work, sing):
    print(b.money)
    #print(b.sing)
    print(b.work)
コード例 #16
0
from baby import Baby

pinky = Baby("Haritha")
pinky.laugh()  # prints "ha..ha..ha"
pinky.cry()  # prints "I am crying"
pinky.hi()  # prints "Hello I am Haritha"

mybaby = Baby()