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
A _ is the acknowledgment of a potential noncomformity, or an opinion regarding an issue that is not covered by a standard
sleet_krkn [62]
Assumption - hope this helped took the test and got 100
5 0
2 years ago
Which SCSI standard allows for the technique known as “hot swapping”? Ultra SCSI Original SCSI Serial SCSI Fast-Wide SCSI
miss Akunina [59]

Answer:

Serial SCSI

Explanation:

Hot swapping can be defined as a process which typically involves fitting or replacing CD-ROM drive, hard-disk drive, power supply or other peripheral devices while a computer system is powered on. Thus, it allows for the installation or removal of a peripheral device from a computer while power is still being supplied to the computer i.e without having to shutdown the computer.

Serial SCSI is a SCSI standard which allows for the technique known as “hot swapping” because it's a point to point connection that is designed to move data to and from computer storage serially.

6 0
3 years ago
What is the purpose of the GETPIVOTDATA function?
Mrac [35]

Answer:to export the PivotTable data into another worksheet

Explanation:hope this helps :D

7 0
2 years ago
Read 2 more answers
Which of the following is a feature that is in the Excel program and NOT in Word? (Select all that apply.)
nikklg [1K]
I believe it is workbooks.
5 0
2 years ago
Computer programming
Svet_ta [14]
Sjanqknjwolq esjkalqlkd
5 0
2 years ago
Other questions:
  • Effective feedback should focus on the behavior, not the person.<br><br> True<br> False
    9·2 answers
  • What do you think of my profile picture
    8·2 answers
  • What is the single most important component of a computer? Central Processing Unit DIP Motherboard Chipset
    8·1 answer
  • Tree diagrams are useful for
    12·1 answer
  • Does anyone know what the name of the game is, where you click on the grey dots in a 3x3 grid and try to make them all the same
    10·1 answer
  • Networking and telecommunications technologies, along with computer hardware, software, data management technology, and the peop
    5·1 answer
  • A data table is a range that displays what?
    15·2 answers
  • I NEED HELP, DO ASAP <br> Why do you have to adjust toys for different ages?
    11·2 answers
  • 2.Some artists look for ways to extend copyright for longer than the laws normally allow. Why do they do this?
    15·1 answer
  • The _____ constraint assigns a value to an attribute when a new row is added to a table
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!