Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IKEA.txt: python problem!! We want to write an inventory program to list some of their quality merchandise! To do this, we want to create a
IKEA.txt:
python problem!!
We want to write an inventory program to list some of their quality merchandise! To do this, we want to create a Furniture object. This represents any item at IKEA. Every IKEA product has a base type, an article number, a price, a Swedish-sounding name, a basic description, and optionally, a colour (or blank if there is no colour). Furniture objects should have the ability to store this. Furniture should, of course, be functionally abstract (that is, it would make no sense to instantiate a Furniture object, as it doesn't have all the code needed to make it actually work it is simply a parent class). It needs an accessor and mutator for the price only. F,301.841.73,9.99, HOLM, Floor lamp - gives a soft mood light, *none*,75,116,22,2.2 F,703.047.29,69.99, ANTIFONI, Floor/reading lamp, nickel plated, 6.3,180,24,2.5 F,902.865.69,49.99, SAMTID, Floor/reading lamp, nickel plated/white, 100,152,25,3.5 F,903.498.97,79.99, YPPERLIG, LED floor lamp, dark gray,7,122,15,3.5 A, 102.335.32,49.00, NOLMYRA, Armless mesh chair, black/black,64,75,75,59,46,40 A,500.395.52,69.99, IKEA PS GULLHOLMEN, Rocking chair, banana fibre, 62,68,75,44,47,34 A, 991.256.71,99.00, PONG, Armchair birch veneer, Ransta red, 68,82,100,56,60,42 A, 403.424.88, 199.00, VEDBO, Armchair, Gunnared dark gray, 75,73,65,45,48,44 N, 702.155.25,19.99, NESNA, Nighstand, bamboo,36,35,45 N,443.611.09,19.99, RAST,Nightstand, pine, 52,30,40 N,603.221.30,39.99, KULLEN, 2-Drawer Chest, black-brown, 35,40,49 N,602.360.24,59.99, TRYSIL, Nighstand, dark brown/black,45,40,53 B, 190.098.21,99.00, FJELLSE,Bed frame, Lury pine, 197,142,33,80 B,490.075.66,179.00, BRUSALI,Bed frame, Lury brown, 208,198,46,93 B, 290.077.94, 189.00, TARVA, Bed frame, Lury pine, 209,160,32,92 B,090.078.13, 199.00, TRYSIL,Bed frame, Lury dark brown, 220,157,40,98 We then want to be able to represent subcategories of their products that we would use in a bedroom (rather than everything they make!) These subcategories should extend (that is, inherit from) Furniture. A Bed also has a length, a width, a footboard height, and a headboard height. These will be expressed in cm. A Nightstand also has width, depth and height, all in cm. An Armchair is their word for a chair, whether it has arms or not. These also have a width, depth, and height, seat width, seat depth, and seat height, all in cm. A Floor Lamp also has a maximum wattage in watts), a height, shade diameter, and cord length. Height and shade diameter are in cm, cord length is in m. You'll note the "also" in each of these. This means that they inherit everything that Furniture has, but they will define more things (behaviours, instance variables) specific to the object in question. You don't have to make accessors and mutators for the subclasses - this will save you time, as the product descriptions are fixed. You will have to make a constructor that can take all these parameters, though. You will need to write a _str_magic method for each object. Read the data from the file ikea.txt - the first item on each row tells you the type of object to be created a single letter), and the rest are parameters as listed above. Have a look at the data file and be sure you understand the format. 1. Read the data, create the specified object, and place it into a list of Furniture. Repeat for each item in the data file. 2. Then, print out each object in the list, and print out the total value of the inventory. The data file will be supplied in this case for you to view. You do NOT need to put that data file anywhere in the Moodle CodeRunner question. It already has it - it's just for your reference. Hints: Furniture should store its data in fully private variables. Furniture should have a _str_method to return its data. Subclasses of Furniture must also take, in their _init_ (constructor methods), the parameters used by Furniture. The first line of a subclass constructor must therefore be super().init(parameters_for_Furniture) where you insert the parameters you're passing to Furniture. The subclasses will also take additional information and store them in their own fully private variables. The subclasses will also have __str_magic methods - these can call on the parent (Furniture) _str_method with super(_str_0 to return part of the String, and save you from having to retype the content generated by the _str_ method of the parent. If you look at similarities between some of the subclasses, you'll quickly realize that, after writing the Armchair class, the Nightstand class could be done very quickly with copy and paste, and some editing. Assume all numbers could have fractional components, including any dimensions, prices, etc. . Do not worry about using dollar signs ($) in the price outputs. Just format them to two decimal places. Sample output: Type: Floor lamp Name: HOLMO Articles 301.841.73 Price: 9.99 Description: Floor lamp - gives a soft mood light Colour: none Wattage: 75.00 Height: 116.00 Shade Diameter: 22.00 Cord Length: 2.20 Type: Floor lamp Name: ANTIFONI Article: 703.047.29 Price: 69.99 Description: Floor/reading lamp Colouri nickel plated Wattage i 6.30 Height180.00 Shade Diameter: 24.00 Cord Length: 2.50 SESSE Type: Floor lamp Name: SAMTID Article: 902.865.69 Price: 49.99 Description: Floor/reading lamp Colour: nickel plated/white Wattage: 100.00 Height : 152.00 Shade Diameter: 25.00 Cord Length: 3.50 Type: Floor lamp Name: YPPERLIG Article: 903.498.97 Price: 79.99 Description: LED floor lamp Colour: dark gray Wattage: 7.00 Height : 122.00 Shade Diameter: 15.00 Cord Length: 3.50 ====== Typer Armchair Name: NOLMYRA Article: 102.335.32 Price: 49.00 Description: Armless mesh chair Colour: black/black Width: 64.00 Depthi 75.00 Height: 75.00 Seat Width: 59.00 Seat Depth: 46.00 Seat Height: 40.00 SEEEEEEEEE EEEEEEEEEE Types Armchair Nume: IKEA PS GULLIOLIN Article: 500.395.52 Price: 69.99 Description: Rocking chair Calor: banana tibre Width: 62.00 Depth: 60.00 Height: 75.00 Seat Width 44.00 Seat Depth: 47.00 Seat Height: 34.00 Type Armchair Sume: PONG Article: 991.256.71 PESCE 99.00 Description: Armohair - birch van Colour: Ranata rad Depth: 12.00 eight: 100.00 Seat Width: 56.00 Sest Depth: 60.00 Seat Height: 42.00 Types Armchair Sme VEDNO Article403.424.00 Price: 199.00 Description Armchair Calort Gunnard dark gray Width: 75.00 Depth: 73.00 Height: 65.00 Seat Width: 45.00 Suat Depth: 48.00 Seat Height: 44.00 Type Nightstand W NESRA Article: 702.155.25 Price 19.99 Description: Nightand Color: bamboo Width: 36.00 Depth: 35.00 Height: 45.00 Type: Nightstand S: RAST Articles 443.611.09 Price 19.99 Description: Nightstand Calort pine Width: 52.00 Depth 30.00 Type: Nightstand Nume: KULLEN Article: G03.221.30 Price: 39.99 Description: 2-De Cheat Color: black-brom Width: 35.00 Depth: 10.00 Height: 49.00 Type: Nightstand Nume: TRYSIL Article 602.360.24 Price: 59.99 Description: Highstand Colour: dark brown/black Width: 45.00 Depth: 40.00 Height: 53.00 Type: Sed Article: 190.090.21 Price: 99.00 Description: led frame Colour: Lurdy pise Length: 197.00 Width: 142.00 Headboard height 10.00 Tootboard Height: 33.00 Type: Bed Nume: BRUSALE Article: 490.075.66 Price: 179.00 Description: Bled frame Color: Lurdy bone Length: 208.00 Width: 19.00 Headboard height: 93.00 Footboard Height: 45.00 Type: Bed : TARVA Article: 290.077.94 Price: 119.00 Description: Bed Frame Calor: Lurdy pine Length: 209.00 Width: 160.00 Headboard height: 92.00 Tootboard Height: 32.00 Type: Bed Sume: TRYSIL Article: 090.070.13 Price: 199.00 Description: Med frame Colour: Lurdy dark brown Length: 220.00 Width: 197.00 Headboard height: 10.00 Tootboard Height: 40.00 Total Tventory Value 1432.91 HINTS The hardest part of Task 1 is figuring out how to parse each line. Consider this: after reading the line, you can split it into its components, as they are comma delimited. You can then use the components as arguments to a construction call on a new object of the appropriate typeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started