Today continues on the basics of classes and objects.
Re-read Chapter 14 up to and including "Classes as Types".
class Midshipman:
def __init__(self, name, alpha, company, oom=1000):
self.name = name
self.alpha = alpha
self.co = company
self.oom = oom
def march(self):
print(self.name, 'is march march marching.')
def switch_company(self, newco):
self.co = newco
def increment_oom(self, amt):
self.oom += amt
mid1 = Midshipman('Chambers', 203452, 23, 50)
mid2 = Midshipman('Herron', 208743, 14, 950)
mid1.march()
mid2.march()
mid2.switch_company(mid1.co)
print(mid1.name, 'is in', mid1.co, 'company')
print(mid2.name, 'is in', mid2.co, 'company')