Write a testprogram that creates two rectangle objects

Assignment Help Computer Engineering
Reference no: EM132112733

Following the example of the Circle class in Section7.2, design a class named Rectangle to represent a rectangle. The classcontains: ¦ Two data fields named width and height .

A constructor that creates a rectangle with the specified width and height .The default values are 1 and 2 for the width and height , respectively.

A method named getArea() that returns the area of this rectangle.

A method named getPerimeter() that returns the perimeter.Draw the UML diagram for the class, and then implement the class.

Write a testprogram that creates two Rectangle objects-one with width 4 and height 40 and the other with width 3.5 and height 35.7 . Display the width, height, area,and perimeter of each rectangle in this order.

7.2

import math

2

3 class Circle:

4 # Construct a circle object

5 def __init__(self, radius = 1 ):

6 self.radius = radius

7

8 def getPerimeter(self):

9 return2 * self.radius * math.pi

10

11 def getArea(self):

12 return self.radius * self.radius * math.pi

13

14 def setRadius(self, radius):

15 self.radius = radius

Reference no: EM132112733

Questions Cloud

Calculate a customers monthly water bill : The program should calculate and display the number of gallons of water used and the total charge for the water.
Parallel implementations - program for a pizza shop : Parallel Implementations - program for a pizza shop - creating the same application in the given programming languages
Write a statement that associates a new value : Write a statement that associates a new value with the first element of the list. The new value should be equal to twice the value of the last element.
Create a dictionary entry with the number : Write a program, dCount(lst,n), which will take a 2-dimensional list which consists of a number (lst[i][0]) and string (lst[i][1]).
Write a testprogram that creates two rectangle objects : Write a testprogram that creates two Rectangle objects-one with width 4 and height 40 and the other with width 3.5 and height 35.7 .
Write a program that uses all of your functions : Write a program that uses all of your functions from above to carry out an RSA key generation, encryption, and decryption.
How could welfare programs exacerbate the problems : How could welfare programs exacerbate the problems they are supposed to cure? The response must be typed, single spaced, must be in times new roman font.
Explain the role of design patterns in the game : Provide a demonstration of the game - how the game play works and how this was implemented - Explain the role of design patterns in the game
What are some examples of in-kind transfers : What are some examples of in-kind transfers? Why do some people prefer that the government provide cash payments to the needy instead of in-kind transfers?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd