예제 #1
0
def main():
	print "We have added more to our Dog and Animal class"

	dog1 = Dog("Spot","BullDog")
	animal1 = Animal("Mickey", "Mouse")

	animal1.getName()
	animal1.getType()

	dog1.getName()
	dog1.getBreed()

	dog1.setName("Pluto")
	dog1.getName()
예제 #2
0
    def save(self):    
        
        # Declare a string named breed, store the contents of the self.breed StringVar
        # in the new string. Hint: use the .get() method. Make sure to trim whitespace in the entry widget!
        breed = self.breed.get().strip()

        # Do the same thing for a new string named name, storing self.name StringVar
        name = self.name.get().strip()

        # Do the same thing for a new string named weight, storing self.weight StringVar
        weight = self.weight.get().strip()
      
        # Do the same thing for a new string named age, storing self.age StringVar
        age = self.age.get().strip()
    

        # Create a new dog object and pass the 4 required parameters to it using the 4 variables you just created.
        # This will store the text in the widgets in the object data fields.
        storeDog = Dog(breed, name, weight, age)
                

        # Declare a new variable named notes, getting and storing the whitespace-trimmed contents of the text widget into it.
        notes = self.text.get('1.0', END).strip()
        
        # declare a new MULTILINE string named savetext, using your 4 Dog class get methods.
        # you will need to concatenate each field of the string with the + operator, and ensure
        # that each field is separated by a line feed.
        # Also, make sure that you add the notes variable at the end of your string definition
        savetext = (storeDog.getBreed() + '\n' + storeDog.getName() + '\n' + storeDog.getWeight() + '\n' + storeDog.getAge() + '\n' + notes)      

        # create a new file object that saves to .txt by default
        filenameforWriting = asksaveasfilename(defaultextension=".txt", filetypes=(("Text file", "*.txt"),("All Files", "*.*") ))
        
        # create a new object named outfile that opens our new filenameforWriting for write operations.
        outfile = open(filenameforWriting, "w")
        
        # write the contents of savetext to the file
        outfile.write(savetext)
        
        # close the file
        outfile.close()
예제 #3
0
from Pet import Pet
from Dog import Dog
mister_dog = Dog("Mister", True)
print (mister_dog.chasesCats())
print(mister_dog.getName())

예제 #4
0
def main():
	dog1 = Dog("Pluto", "Hound")

	print dog1.getName()

	print dog1.getBreed()