Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

from math import * print(Assignment 6.1) print(Author: Mingxian Jin) print(Date: ##/##/2018) print( ) print(Part 1. Create a class Rectangle with simple construction of objects,) print(accessing

from math import *

print("Assignment 6.1")

print("Author: Mingxian Jin")

print("Date: ##/##/2018")

print(" ")

print("Part 1. Create a class Rectangle with simple construction of

objects,")

print("accessing of rectangle, and possibility of setting the parameters

of ")

print("a rectangle based on the Point Example. ")

print("Part 2. Modify the class Rectangle i.e. include construction of ")

print("an object with arguments, modify creating string description of the

")

print("rectangle, computing diagonal of the rectangle, scaling rectangle,

")

print("shifting rectangle, normalizing rectangle (setting its down-left

corner ")

print("is in the origin and making diagonal equal to 1).")

class Rectangle():

def __init__(self, initX1=0, initY1=0, initX2=1, initY2=1):

self._x1 = initX1

self._y1 = initY1

# place your code ...

def getX1(self):

# place your code ...

def getY1(self):

# place our code ...

def getX2(self):

# place your code ...

def getY2(self):

# place your code ...

def setX1(self, val):

# place your code ...

def setY1(self, val):

# place your code ...

def setX2(self, val):

# place your code ...

def setY2(self, val):

# place your code ...

def scale(self, factor):

# place your code ...

def diagonal(self):

# place your code ...

return sqrt((side1*side1)+(side2*side2))

def normalize(self):

# place your code ...

def shift(self, distX, distY)

# shift x1, y1, x2, y2 with the provided distance

# place your code ...

def __str__(self):

# place our code ...

# return in the format of

# Test class Rectangle

# Part 1 a. b. c. code for rectangle1 below

rectangle1 = Rectangle()

# Part 2 d. e. f. code for rectangle2 below

rectangle2 = Rectangle()

# Part 2 g. h. code for rectangle2 below

# Part 2 i. j. k. l. code for rectangle3 below

rectangle3 = Rectangle()

^^^^^^^^^^^my code so far^^^^^^^^^ write it in python code!!!!

(a) with the name Assignment 6.1 appended to your last name

(b) containing print statement to display the name of the assignment i.e. Assignment 6.1

(c) containing print statement to display the name of the programmer (student)

(d) containing print statement to display the date when the assignment was uploaded

(e) for each problem within the assignment include print statement to display the problem number or letter

(f) for each problem within the assignment include print statement to display the problem description

(g) for each problem within the assignment write commands and display the result with the text Result:

Part 1. Create a class Rectangle with simple construction of objects, accessing of rectangle, and possibility of setting the parameters of a rectangle based on the Point Example. Test your code:

a. Create rectangle rectangle1

b. Set parameters of the rectangle so that its down-left corner is in the origin and the up-right corner has position <2,2>

c. Print the values of position of down-left corner and the up-right corner

Part 2. Modify the class Rectangle i.e. include construction of an object with arguments, modify creating string description of the rectangle, computing diagonal of the rectangle, scaling rectangle, shifting rectangle, normalizing rectangle ( setting its down-left corner is in the origin and making diagonal equal to 1) based on the Point example. Test your code:

d. Create rectangle rectangle2 with its down-left corner is in the origin and with the up-right corner in position <2,2>

e. Print the values of position of down-left corner and the up-right corner

f. Print the value of the string describing rectangle2

g. Compute and print diagonal of rectangle2

h. Normalize rectangle2 and print the value of the string describing new rectangle2

i. Create rectangle rectangle3 with its down-left corner in position <1,1> and with the up-right corner in position <3,2>

j. Print the value of the string describing rectangle3

k. Compute and print diagonal of rectangle3

l. Shift rectangle3 with +3 horizontally +2 vertically and print the value of the string describing new rectangle3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions