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
Anyone know how to fix this problem on Microsoft Team?
lesya [120]

Answer:

Wait for some time and reload the page

Fix the corrupted file

The file is deleted before finishing upload

Clear browser cache.

Explanation:

7 0
2 years ago
Read 2 more answers
A feature that displays in the lower right corner of a selected range with which you can analyze your data by using Excel tools
bagirrra123 [75]

Answer:

Quick analysis tool.

Explanation:

Excel is a spreadsheet application package found in the Microsoft office suite. it's environment on the display screen is called a worksheet and a collection of the worksheets is called a workbook. The excel packet is used for data analysis and interpretation and presentation.

When a group of cells in a worksheet is selected, a small tool kit appears that the lower right corner, it is known as a quick analysis tool. It is use for easy and fast analysis and formatting of that selected group.

5 0
2 years ago
Read 2 more answers
Households play a role in the circular flow of goods by
BaLLatris [955]

Answer:

People in households buy goods and services from businesses in an attempt to satisfy their unlimited needs and wants.

Explanation:

Households also sell their labor, land, and capital in exchange for income that they use to buy goods and services that firms produce.

6 0
3 years ago
What is the different between the simple statement and compound statement ?​
OverLord2011 [107]

Answer:

Following is the difference between Simple and Compound statement; Simple statement (sentence) is one which has only one subject and one predicate. A Compound statement (sentence) is one which has two or more independent clauses consisting of their own subject and predicate.

Explanation:

hope it helps you

Mark as brainliest.

And follow for a follow back

4 0
2 years ago
Use semaphore(s) to solve the following problem. There are three processes: P1, P2, and P3. Each process Pi has a segment of cod
Lisa [10]

Answer:

See explaination

Explanation:

Here we will use two semaphore variables to satisfy our goal

We will initialize s1=1 and s2=1 globally and they are accessed by all 3 processes and use up and down operations in following way

Code:-

s1,s2=1

P1 P2 P3

P(s1)

P(s2)

C1

V(s2) .

P(s2). .

. C2

V(s1) .

P(s1)

. . C3

V(s2)

Explanation:-

The P(s1) stands for down operation for semaphore s1 and V(s1) stands for Up operation for semaphore s1.

The Down operation on s1=1 will make it s1=0 and our process will execute ,and down on s1=0 will block the process

The Up operation on s1=0 will unblock the process and on s1=1 will be normal execution of process

Now in the above code:

1)If C1 is executed first then it means down on s1,s2 will make it zero and up on s2 will make it 1, so in that case C3 cannot execute because P3 has down operation on s1 before C3 ,so C2 will execute by performing down on s2 and after that Up on s1 will be done by P2 and then C3 can execute

So our first condition gets satisfied

2)If C1 is not executed earlier means:-

a)If C2 is executed by performing down on S2 then s2=0,so definitely C3 will be executed because down(s2) in case of C1 will block the process P1 and after C3 execute Up operation on s2 ,C1 can execute because P1 gets unblocked .

b)If C3 is executed by performing down on s1 then s1=0 ,so definitely C2 will be executed now ,because down on s1 will block the process P1 and after that P2 will perform up on s1 ,so P1 gets unblocked

So C1 will be executed after C2 and C3 ,hence our 2nd condition satisfied.

4 0
3 years ago
Other questions:
  • What is meant by polling mode in communication between software andUART and what is its disadvantage as compared to interrupt mo
    14·1 answer
  • Drag each label to the correct image.
    9·2 answers
  • Shape is very prominent in the image of the telephone other elements are ( Color, Space, or Line) and (Form, Space, or Texture)
    15·2 answers
  • Which table attributes would this code produce?
    15·1 answer
  • What to do if your monitor is not displaying a picture
    12·1 answer
  • This is for career exploration, I need help please! <3 HELPPPP
    8·2 answers
  • Explain the concept of “survival of the fittest”
    15·1 answer
  • 2. How does the internet give us the ability to communicate?
    15·1 answer
  • The act of using computer equipment to “break into” the computer systems of others?
    6·1 answer
  • Help fast pls
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!