I included some code below which is coded using each dimension as it's own class/object.
class Iron(object) :
"""general parent class for iron objects"""
def __init__(self,measurement) :
self.measurement=float(measurement)
def getMeasurement(self) :
return self.measurement
def setMeasurement(self,measurement) :
self.measurement=float(measurement)
class IronLength(Iron) :
"""create an iron length object and set it's measurement"""
def __init__(self,length) :
super(IronLength,self).__init__(length)
class IronBore(Iron) :
"""create an iron bore object and set the iron bore measurement"""
def __init__(self,bore) :
super(IronBore,self).__init__(bore)
class IronTooth(Iron) :
"""create and iron tooth object and set the iron tooth width measurement"""
def __init__(self,tooth) :
super(IronTooth,self).__init__(tooth)
class IronBackiron(Iron) :
"""create an iron backiron object and set the iron backiron measurement"""
def __init__(self,backiron) :
super(IronBackiron,self).__init__(backiron)
class IronSlotDepth(Iron) :
"""create an iron slot depth object and set the iron slot depth measurement"""
def __init__(self,depth) :
super(IronSlotDepth,self).__init__(depth)
class IronVent(Iron) :
"""create an iron vent object and set the vent width, number of vents and total vent width of any iron vents"""
def __init__(self,vent,numvents=0) :
super(IronVent,self).__init__(vent)
self.numvents=int(numvents)
self.ventwidth=self.getMeasurement()
def getNumVents(self) :
return self.numvents
def getVentWidth(self) :
return self.ventwidth
def getTotalVents(self) :
self.totalvents=self.getVentWidth()*self.getNumVents()
return self.totalvents
ironlength=IronLength(float(input("please enter iron length measurement")))
ironbore=IronBore(float(input("please enter iron bore measurement")))
irontooth=IronTooth(float(input("Please enter the tooth measurement")))
ironback=IronBackiron(float(input("please enter backiron measurement")))
ironslotdepth=IronSlotDepth(float(input("please enter slot depth measurement")))
numvents=int(input("please enter number of vents"))
ironventwidth=IronVent(float(input("please enter vent width measurement")),numvents=numvents)
ironlengthtotal=ironlength.getMeasurement()-ironventwidth.getTotalVents()
print("Iron Dimensions Entered")
print("Iron Length: "+str(ironlength.getMeasurement()) )
print("Iron Bore: "+str(ironbore.getMeasurement()) )
print("Iron Tooth: "+str(irontooth.getMeasurement()) )
print("Iron Backiron: "+str(ironback.getMeasurement()) )
print("Iron Slot Depth: "+str(ironslotdepth.getMeasurement()) )
print("Iron Number Of Vents: "+str(numvents))
print("Iron Vent Width: " +str(ironventwidth.getVentWidth()) )
print("Iron Length Total: "+str(ironlengthtotal) )

New Topic/Question
Reply




MultiQuote




|