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
What are the oop concept of java
mash [69]

Answer: OOP concepts in Java are the main ideas behind Java’s Object Oriented Programming. They are abstraction, encapsulation, inheritance, and polymorphism. Grasping them is key to understanding how Java works. Basically, Java OOP concepts let us create working methods and variables, then re-use all or part of them without compromising security.

HOPE THIS HELPED IS NOT SORRY.

4 0
2 years ago
Read 2 more answers
A loop that will output only the names that come before "Thor" in the alphabet from the names list.
matrenka [14]

names = ["Kevin", "Joe", "Thor", "Adam", "Zoe"]

names.sort()

for x in names:

   if x == "Thor":

       break

   else:

       print(x)

I made up my own names for the sake of testing my code. I wrote my code in python 3.8. I hope this helps.

3 0
3 years ago
You are designing software for elderly people. Which two features can you
romanna [79]

give instructions in both text and audio formats

7 0
3 years ago
How is the number 110 written when expanded out to place values in the base 2 (binary) number system?
Vinil7 [7]
C is correct answer ......
3 0
3 years ago
At least one method in an abstract class must be abstract. <br> a. True <br> b. False
azamat

your answer is A: ture

5 0
3 years ago
Other questions:
  • Which is a common problem caused by the widespread use of computers?
    7·1 answer
  • Which group of commands all appear on the Standard toolbar?
    9·2 answers
  • The following equations estimate the calories burned when exercising (source): Men: Calories = ( (Age x 0.2017) — (Weight x 0.09
    11·1 answer
  • Write a program whose input is a string which contains a character and a phrase, and whose output indicates the number of times
    6·1 answer
  • analyze the ethical issues in the use of information technology in Multinational company (MNC) and support you answer with one e
    15·1 answer
  • Some printers spray ink, while others use heat or lasers to create images.
    14·2 answers
  • Which type of network is the internet? choose the answer
    8·1 answer
  • One can find mountain ranges, elevation levels, and deserts on a physical map.
    15·2 answers
  • Under the Home tab, controls for aligning text and objects can be found in the
    5·2 answers
  • A transistor may be used as an amplifier in an electronic circuit. <br> Select one: True False
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!