Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Object Oriented Programming using python Problem 1: Fractions Create a simple class to represent a number as a fraction where your class will take the

Object Oriented Programming using python
Problem 1: Fractions
Create a simple class to represent a number as a fraction where your class will take the numerator and denominator as parameters.
Implement features to add, subtract, multiply, divide, return decimal value, and inverse your fraction object as indicated in the given file.
Create a CFraction class which has all the same features as the first fraction class (hint: subclass) but makes sure the fraction is in its most simplified form (e.g. 1/2 instead of 5/10).
Hint: to simplify fractions you will need the greatest common divisor, a non-recursive gcd() and recursive gcdr() functions are provided,
Please comment in a very brief explanation for gcd(), gcdr(), primeFactors(), and prod() on what the functions do. Refer to the wiki on Greatest Common Divisor.
Use the operations and print statements provided to test your code.
Problem 2: Furniture
You are given several classes relating to a home.
You need to calculate the total value of the house by adding the price of the house and all its furniture by adding prices to the furniture.
Idea: You might want to introduce a class "Furniture", with an attribute "value" and subclasses for sofa and table. To the house you may want to add a list of furniture.
Sort the houses by
1. total area
2. lexicographically by (rooms, size, owner)
3. total value
*** Reminders
For this lab please submit python files.
Please include your name in the header of the python files.
Use enter and tabs for indentation instead of spaces to avoid indentation errors.
Remember to test your code using the python console.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago