Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. # Create the Robot class
  2. class Robot(object):
  3.     # Set default parameters
  4.     def __init__(self, name, model, color):
  5.         self.name = name
  6.         self.model = model
  7.         self.color = color
  8.     # Use hyphen as string delimiter
  9.     @classmethod
  10.     def one_string(cls, my_str):
  11.         name, model, color = my_str.split('-')
  12.         return cls(name, model, color)
  13.  
  14.     # Print robot information provided by object
  15.     def robotInfo(self):
  16.         print('Name: %s\nModel: %s\nColor: %s' % (self.name, self.model, self.color))
  17.  
  18.     # Methods called from main
  19.     @classmethod
  20.     def check(cls):
  21.         state = input("Is the shelf full? Enter 'Y\' for yes or 'N\' for no: ").upper()
  22.         return state
  23.  
  24.     @classmethod
  25.     def fetch(cls):
  26.         stockExists = input("Is there product available in the backroom? Enter 'Y\' for yes or 'N\' for no: ").upper()
  27.         if stockExists == 'Y':
  28.             print("\nAltman will stock the product on the shelf. Will return to backroom to sleep when finished.")
  29.         elif stockExists == 'N':
  30.             print("\nNo product available to stock. Returning to backroom to sleep.")
  31.         else:
  32.             print("\nInvalid entry.")
  33.  
  34.     @classmethod
  35.     def sleep(cls):
  36.         print('\nShelves full. Altman returning to backroom to sleep.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement