Question: Python3 Code Help Please! Test Cases: def test_Wheel_02(self): c1 = Cylinder(1,1) c2 = Cylinder(2,1) c3 = Cylinder(30,5) c4 = Cylinder(47,5) m1 = Material(1,Tin) m2 =

Python3 Code Help Please!

Python3 Code Help Please! Test Cases: def test_Wheel_02(self): c1 = Cylinder(1,1) c2

Test Cases:

= Cylinder(2,1) c3 = Cylinder(30,5) c4 = Cylinder(47,5) m1 = Material(1,"Tin") m2

def test_Wheel_02(self):

c1 = Cylinder(1,1)

c2 = Cylinder(2,1)

c3 = Cylinder(30,5)

c4 = Cylinder(47,5)

m1 = Material(1,"Tin")

m2 = Material(75,"Silver")

m3 = Material(217,"Gold")

m4 = Material(10000,"Magic")

w1 = Wheel(c1, c2, m1)

self.assertEqual(str(w1), 'Wheel: \tMaterial: Tin (cost per cm^3: $0.01) \tOuter: Cylinder (radius: 1.00mm, thickness: 1.00mm, volume: 3.14mm^3) \tInner: Cylinder (radius: 0.50mm, thickness: 1.00mm, volume: 0.79mm^3) \tVolume: 2.36mm^3 \tUnit Cost: $0.01')

w2 = Wheel(c1, c2, m2)

self.assertEqual(str(w2), 'Wheel: \tMaterial: Silver (cost per cm^3: $0.75) \tOuter: Cylinder (radius: 1.00mm, thickness: 1.00mm, volume: 3.14mm^3) \tInner: Cylinder (radius: 0.50mm, thickness: 1.00mm, volume: 0.79mm^3) \tVolume: 2.36mm^3 \tUnit Cost: $0.75')

w3 = Wheel(c3, c4, m3)

self.assertEqual(str(w3), 'Wheel: \tMaterial: Gold (cost per cm^3: $2.17) \tOuter: Cylinder (radius: 23.50mm, thickness: 5.00mm, volume: 8674.72mm^3) \tInner: Cylinder (radius: 15.00mm, thickness: 5.00mm, volume: 3534.29mm^3) \tVolume: 5140.43mm^3 \tUnit Cost: $13.02')

w4 = Wheel(c3, c4, m4)

self.assertEqual(str(w4), 'Wheel: \tMaterial: Magic (cost per cm^3: $100.00) \tOuter: Cylinder (radius: 23.50mm, thickness: 5.00mm, volume: 8674.72mm^3) \tInner: Cylinder (radius: 15.00mm, thickness: 5.00mm, volume: 3534.29mm^3) \tVolume: 5140.43mm^3 \tUnit Cost: $600.00')

w5 = Wheel(c1, c2, m4)

self.assertEqual(str(w5), 'Wheel: \tMaterial: Magic (cost per cm^3: $100.00) \tOuter: Cylinder (radius: 1.00mm, thickness: 1.00mm, volume: 3.14mm^3) \tInner: Cylinder (radius: 0.50mm, thickness: 1.00mm, volume: 0.79mm^3) \tVolume: 2.36mm^3 \tUnit Cost: $100.00')

= Material(75,"Silver") m3 = Material(217,"Gold") m4 = Material(10000,"Magic") w1 = Wheel(c1, c2,

m1) self.assertEqual(str(w1), 'Wheel: \tMaterial: Tin (cost per cm^3: $0.01) \tOuter: Cylinder (radius:

1.00mm, thickness: 1.00mm, volume: 3.14mm^3) \tInner: Cylinder (radius: 0.50mm, thickness: 1.00mm, volume:

Cylinder Class:

import math

class Cylinder(object):

def __init__(self, diameter, height):

self.diameter = diameter

self.height = height

def get_volume(self):

radius = self.diameter/2.0

return math.pi*(radius**2)*self.height

def __str__(self):

s = "Cylinder (radius: %.2fmm, thickness: %.2fmm, volume: %.2fmm^3)" % (self.diameter/2.0, self.height, self.get_volume())

return s

def __eq__(self,other):

return (self.diameter == other.diameter and self.height == other.height)

def __hash__(self):

return hash((self.diameter, self.height))

Wheel class: Instance variables: Make instance variables appropriately to accomplish the tasks you need. . init_:: constructor, initializes instance variables o Additional Parameters: inner, outer, and material in that order) o Assumptions: "inner and outer will be instances of Cylinders which represent the inner cutout and the outer wheel (respectively)-see Project 1 if you don't remember this... material will be an instance of a Material Temporary Assumptions (we will fix these later): " inner and outer will have the same height o . inner will be smaller than outer returns the volume of the wheel in millimeters cubed. . get_volume o o Additional Parameters: No additional parameters. Remember: You can get the volume of a cylinder using the methods of the Cylinder class! get_cost :: returns the cost of some number of wheels (in cents) based on the volume and the material being used. Like in Project 1, you must buy material in whole units (millimeters cubed), so round up to the nearest unit if there is a fraction of material needed. . o Additional Parameters: number_of_wheels (default value of 1). o Assumption: number_of_wheels represents how many wheels will be ordered. o Temporary Assumption (we will fix this later): number_of wheels will never be negative o Remember: You can get the volume of a wheel using the method you already wrote for the Wheel class and the cost for some number of units of material from a method you wrote for the Material class. Just remember that materials are in centimeters and your cylinders are in millimeters and, like in Project 1, you can combine material for multiple wheels for the cost. str:returns string representation with this format: heel: Material: Silver (cost per cm^3: $0.76) Outer: Cylinder (radius: 28.25mm, thickness: 6.18mm, volume: 7858.32mm3) Inner: Cylinder(radius: 1.68mm, thickness: 6.18mm, volume: 49.86mm*3) Volune: 7889.26mm3 Unit Cost: $68.84" o Additional Parameters: No additional parameters. o Notes: The quotes in the example are just our string boundaries! The first character in the above example is W. There are tabs in front of Material, Outer Inner, etc. Volume and unit cost are both represented with two decimal places. Remember: You already wrote methods to convert materials and cylinders to strings, use them! o . eq: returns true or false depending on whether the current instance (self) is equal to some other instance (other). Two wheels are equal if they have the same inner and outer measurements as well as the same material. o Parameters: eq requires the parameters self and other (in that order) o Assumption: other will always be an instance of a Wheel o Remember: If you wrote the_eq_method for Cylinder and Material, you can now compare two cylinders (or two materials) with Wheel class: Instance variables: Make instance variables appropriately to accomplish the tasks you need. . init_:: constructor, initializes instance variables o Additional Parameters: inner, outer, and material in that order) o Assumptions: "inner and outer will be instances of Cylinders which represent the inner cutout and the outer wheel (respectively)-see Project 1 if you don't remember this... material will be an instance of a Material Temporary Assumptions (we will fix these later): " inner and outer will have the same height o . inner will be smaller than outer returns the volume of the wheel in millimeters cubed. . get_volume o o Additional Parameters: No additional parameters. Remember: You can get the volume of a cylinder using the methods of the Cylinder class! get_cost :: returns the cost of some number of wheels (in cents) based on the volume and the material being used. Like in Project 1, you must buy material in whole units (millimeters cubed), so round up to the nearest unit if there is a fraction of material needed. . o Additional Parameters: number_of_wheels (default value of 1). o Assumption: number_of_wheels represents how many wheels will be ordered. o Temporary Assumption (we will fix this later): number_of wheels will never be negative o Remember: You can get the volume of a wheel using the method you already wrote for the Wheel class and the cost for some number of units of material from a method you wrote for the Material class. Just remember that materials are in centimeters and your cylinders are in millimeters and, like in Project 1, you can combine material for multiple wheels for the cost. str:returns string representation with this format: heel: Material: Silver (cost per cm^3: $0.76) Outer: Cylinder (radius: 28.25mm, thickness: 6.18mm, volume: 7858.32mm3) Inner: Cylinder(radius: 1.68mm, thickness: 6.18mm, volume: 49.86mm*3) Volune: 7889.26mm3 Unit Cost: $68.84" o Additional Parameters: No additional parameters. o Notes: The quotes in the example are just our string boundaries! The first character in the above example is W. There are tabs in front of Material, Outer Inner, etc. Volume and unit cost are both represented with two decimal places. Remember: You already wrote methods to convert materials and cylinders to strings, use them! o . eq: returns true or false depending on whether the current instance (self) is equal to some other instance (other). Two wheels are equal if they have the same inner and outer measurements as well as the same material. o Parameters: eq requires the parameters self and other (in that order) o Assumption: other will always be an instance of a Wheel o Remember: If you wrote the_eq_method for Cylinder and Material, you can now compare two cylinders (or two materials) with

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!