Advertisement
Guest User

Untitled

a guest
Nov 13th, 2013
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.99 KB | None | 0 0
  1. Second class Shocks() is taking parameters from original Rallycars()
  2. Rallycars determines the minimum permissible weight according to regulations for every category.
  3. According to the data contained in Rallyclass, Shocks() will let the team know which suspension system should be installed for each kind of car.
  4.  
  5. # -*- coding: iso-8859-15 -*-
  6.  
  7. class Rallycar(object):
  8.     "Different categories inside Rally regulations"
  9.     def __init__(self,  make, model,  type):
  10.         self.make = make
  11.         self.model = model
  12.         self.type = type
  13.     def minimumweight(self):
  14.         if self.type.upper() == 'R1':
  15.             minimum = 980
  16.         elif self.type.upper() == 'R2':
  17.             minimum = 1050
  18.         elif self.type.upper() == 'R3':
  19.             minimum = 1150
  20.         elif self.type.upper() == 'R4':
  21.             minimum = 1200
  22.         elif self.type.upper() == 'R5':
  23.             minimum = 1280
  24.         else:
  25.             print "invalid class"
  26.             exit()
  27.         return minimum
  28.  
  29. class Shocks(object):
  30.     "Each different car class uses different suspension systems"
  31.     def __init__(self,  type,  make,  model):
  32.         self.type = type
  33.         self.model = model
  34.         self.make = make
  35.     def shocktype(self):
  36.         if self.type.upper() == 'R1':
  37.             print '%s %s must equip Bilstein monotube'% (self.make,  self.model)
  38.         elif self.type.upper() == 'R2':
  39.             print '%s %s must equip Ohlins two way'% (self.make,  self.model)
  40.         elif self.type.upper() == 'R3':
  41.             print '%s %s must equip Teknoshock three way'% (self.make,  self.model)
  42.         elif self.type.upper() == 'R4' or 'R5':
  43.             print '%s %s must equip Ohlins 4 way'% (self.make,  self.model)
  44.        
  45. marca = raw_input('marca  ')
  46. modelo = raw_input('modelo  ')
  47. tipo = raw_input('tipo  ')
  48. a = Rallycar(marca,  modelo,  tipo)
  49. b = Shocks(a.type,  a.make,  a.model)
  50. b.shocktype()
  51. print 'The minimum legal weight will be %d'%(a.minimumweight())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement