1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
anastassius [24]
3 years ago
15

Implement a program that manages shapes. Implement a class named Shape with a method area() which returns the double value 0.0.

Implement three derived classes named Rectangle, Square, and Circle. Declare necessary properties in each including getter and setter function and a constructor that sets the values of these properties. Override the area() function in each by calculating the area using the defined properties in that class.
Computers and Technology
1 answer:
Tamiku [17]3 years ago
8 0

Answer:

Explanation:

The following code is written in Python. It creates the parent class Shape and the three subclasses Rectangle, Square, and Circle that extend Shape. Shape has the constructor which is empty and the area method which returns 0.0, while the three subclasses take in the necessary measurements for its constructor. Each subclass also has getter and setter methods for each variable and an overriden area() method which returns the shapes area.

class Shape:

   def __init__(self):

       pass

   def area(self):

       return 0.0

class Square(Shape):

   _length = 0

   _width = 0

   def __init__(self, length, width):

       self._width = width

       self._length = length

   def area(self):

       area = self._length * self._width

       return area

   def get_length(self):

       return self._length

   def get_width(self):

       return self._width

   def set_length(self, length):

       self._length = length

   def set_width(self, width):

       self._width = width

class Rectangle(Shape):

   _length = 0

   _width = 0

   def __init__(self, length, width):

       self._width = width

       self._length = length

   def area(self):

       area = self._length * self._width

       return area

   def get_length(self):

       return self._length

   def get_width(self):

       return self._width

   def set_length(self, length):

       self._length = length

   def set_width(self, width):

       self._width = width

class Circle(Shape):

   _radius = 0

   def __init__(self, radius):

       self._radius = radius

   def area(self):

       area = 2 * 3.14 * self._radius

       return area

   def get_radius(self):

       return self._radius

   def set_radius(self, radius):

       self._radius = radius

You might be interested in
According to the lecture, when communicating men prefer to concentrate on _____________.
liq [111]

Answer: D.) All of the above. (happy to help)

Explanation: A.)

problem solving

B.)

expertise

C.)

content

D.)

all of the above

6 0
3 years ago
It's inventiveness uncertainty and futuristic ideas typically deals with science and technology ......what is it.
marshall27 [118]

Answer:

Necessity is the mother of invention, technology is a tool to aid invention, and science is exploratory means to new ideas and information to approach our future with preparedness.All are necessary and need to be balanced and scrutinised.

Explanation:

5 0
3 years ago
A business letter should always include the address of the sender.<br> True<br> False
8090 [49]

Answer:

true

Explanation:it is true because like that they could send that letter were it go's so like that they don't have trouble looking for the person's letter

please mark me as brainlist

3 0
3 years ago
Read 2 more answers
Type of file containing instructions that tell your computer how to perform ___
julsineya [31]

Answer:

A)File

B)Native

C)Extension

D)File size

Explanation:

6 0
3 years ago
What is the term for the era created by the digital revolution?
ollegr [7]
We are in the modern era and the information era
8 0
3 years ago
Other questions:
  • Ports on the motherboard can be disabled or enabled in ____ setup. RAM Firmware Northbridge BIOS
    8·1 answer
  • What would happen if a pc that contains a power supply that does not automatically adjust for input voltage is set to 230 volts
    13·1 answer
  • A typical self-expelling fire extinguisher empties its contents in
    8·1 answer
  • 30
    5·1 answer
  • What are some characteristics of filtering junk email in Outlook 2016? Check all that apply.
    9·2 answers
  • What language must be used to display a bare-minimum webpage?
    8·2 answers
  • Which descriptions offer examples of Correction Services workers? Select all that apply.
    8·1 answer
  • An IT suspects that an unauthorized device is connected to a wireless network. This is a result of passkey sharing on a device b
    14·1 answer
  • The people on this platform are unbelievably nice. its almost rare to see this type of kindness online these days. Just wanted t
    14·1 answer
  • If you want to create a line of code that will not appear in the interpreter, what symbol should begin the line?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!