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 is the different thing about search engines and various components?
alexandr1967 [171]

Answer: A search engine normally consists of four components e.g. search interface, crawler (also known as a spider or bot),indexer, and database. The crawler traverses a document collection, deconstructs document text, and assigns surrogates for storage in the search engine index.

Explanation:

6 0
3 years ago
Write a program that stores the value 16 in the variable length and the value 18 in the variable width. Have your program calcul
drek231 [11]

Answer:

#include<iostream>

using namespace std;

int main()

{

  int length = 16;

   int width = 18;

   int perimeter = (2*length) + (2 * width);

   cout<<"The perimeter is: "<<perimeter<<endl;

}

Explanation:

First include the library iostream in the c++ program for input/output.

then, create the main function and define the variable with given values in the length and width.

After that calculate the perimeter by using the formula.

perimeter = 2*length + 2*width

and finally display the output  on the screen by using the cout instruction.

8 0
4 years ago
You are the network administrator for a growing business. When you were hired, the organization was small, and only a single swi
jek_recluse [69]

Answer:

-use syslog to implement centralized logging

Explanation:

3 0
3 years ago
A(n) is a combination of a mobile phone and handheld computer
Nataly [62]
A phone / mobile device
3 0
3 years ago
Black Ops 3 For Ps4 Players Here
masha68 [24]

Answer:

Love black ops

6 0
3 years ago
Other questions:
  • Google+ hangouts is connected to what other social media site?
    8·1 answer
  • To easily add an organizational chart to a document, users should select _____. SmartArt Text Boxes Shapes Clip Art
    8·2 answers
  • Consider the following two implementations of the same algorithm, each written in a different language.
    11·1 answer
  • Teachers in most school districts are paid on a schedule that provides a salary based on their number of years of teaching exper
    7·1 answer
  • Select the education or qualification that is best demonstrated in each example Freda interviews a famous local athlete on a tel
    8·1 answer
  • During the name resolution process, which technique is used to avoid congestion when querying a server
    8·1 answer
  • PLEASE HURRY PLEASE HELP THIS CLASS ENDS TODAY AND I NEED HELP
    7·1 answer
  • Who is the first British in Europe ​
    10·1 answer
  • To create a presentation completely by yourself, which option do you use?​
    10·1 answer
  • I need help! Please please
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!