Python OOP with Dynamic Typing

Online tutoring services

Need help with this question or any other Computer Science assignment help task? Click on the button below to to hire an expert cheap.

I need help with this short Python homework about shapes, link to the assignment page is here https://sites.google.com/cs.stonybrook.edu/cse-216/assignments_1/assignment-5-oop-with-dynamic-typing


You can download the code on the page or you can also see the attached files below.


Some clarifications- in order to check equality of shapes for each class, you want them to have the same type and same coordinates. For the TwoDPoint Class,where the TODO magic method is, p is self and q is other, and adding/subtracting would mean x1-x2 and so on.

Get Help With a similar task to - Python OOP with Dynamic Typing

Login to view and/or buy answers.. or post an answer
Additional Instructions:
hw5codebase/quadrilateral.py from .two_d_point import TwoDPoint from typing import Tuple class Quadrilateral: def __init__(self, *floats): points = TwoDPoint.from_coordinates(list(floats)) self.__vertices = tuple(points[0:3]) @property def vertices(self): return self.__vertices def side_lengths(self): """Returns a tuple of four floats, each denoting the length of a side of this quadrilateral. The value must be ordered clockwise, starting from the top left corner.""" return 0, 0, 0, 0 # TODO def smallest_x(self): """Returns the x-coordinate of the vertex with the smallest x-value of the four vertices of this quadrilateral.""" return 0 # TODO hw5codebase/rectangle.py from .quadrilateral import Quadrilateral from .two_d_point import TwoDPoint class Rectangle(Quadrilateral): def __init__(self, *floats): super().__init__(*floats) if not self.__is_member(): raise TypeError("A rectangle cannot be formed by the given coordinates.") def __is_member(self): """Returns True if the given coordinates form a valid rectangle, and False otherwise.""" return False # TODO def center(self): """Returns the center of this rectangle, calculated to be the point of intersection of its diagonals.""" return TwoDPoint(0, 0) # TODO def area(self): """Returns the area of this rectangle. The implementation invokes the side_lengths() method from the superclass, and computes the product of this rectangle's length and width.""" return 0 # TODO hw5codebase/square.py from .rectangle import Rectangle from .quadrilateral import Quadrilateral class Square(Rectangle): def __init__(self, *floats): super().__init__(*floats) if not self.__is_member(): raise TypeError("A square cannot be formed by the given coordinates.") def snap(self): """Snaps the sides of the square such that each corner (x,y) is modified to be a corner (x',y') where x' is the integer value closest to x and y' is the integer value closest to y. This, of course, may change the shape to a general quadrilateral, hence the return type. The only exception is when the square is positioned in a way where this approximation will lead it to vanish into a single point. In that case, a call to snap() will not modify this square in any way.""" return Quadrilateral() # TODO hw5codebase/two_d_point.py from typing import List class TwoDPoint: def __init__(self, x, y) -> None: self.__x = x self.__y = y @property def x(self): return self.__x @property def y(self): return self.__y def __eq__(self, other: object) -> bool: return False # TODO def __ne__(self, other: object) -> bool: return not self.__eq__(other) def __str__(self) -> str: return '(%g, %g)' % (self.__x, self.__y) # TODO: add magic methods such that two TwoDPoint objects can be added and subtracted coordinate-wise just by using # syntax of the form p + q or p - q @staticmethod def from_coordinates(coordinates: List[float]): if len(coordinates) % 2 != 0: raise Exception("Odd number of floats given to build a list of 2-d points") points = [] it = iter(coordinates) for x in it: points.append(TwoDPoint(x, next(it))) return points

Related Questions

Similar orders to Python OOP with Dynamic Typing
4
Views
0
Answers
Practical Project, reading files and creating an output array
https://www.cs.colostate.edu/~cs163/.Fall21/practicals/p3/ The link will take you to the instructions, all files needed are attached there with instructions on methods, variables, etc...
17
Views
0
Answers
Modeling a Relational Database in MySQL
You will need to submit the entity relationship data model in MWB format with a screenshot either in JPG or PNG format, after adding at least three records to each table. The logical model should include the tables, attributes, keys, mandatory role constraints, and referential integrity constraints. I will also need the output script in SQL format or text-based file after forward engineering the designed ER-model....
44
Views
0
Answers
MyLabIT Excel Lab 7 easy and fast! need by sunday
Hello! I need someone to complete a lab for me in my excel class. This lab is accessed through Pearson MyLabIT, it is due by Sunday October 17, 11:59pm would need it sent and done before that last minute. The file I have uploaded is the assignment that is needed to be done and sent back to me. The numbers underneath each instruction is how much points it is worth. Thank You!! Here are the Instructions: Start Excel. Download and open the file named Exp19_Excel_Ch07_Cap_RealEstate.xlsx. Grader has automatically added your last name to the beginning of the filename. 0 2 The spreadsheet contains codes (BA, DA, SA) to represent agent roles (Buyer’s Agent, Dual Agent, Seller’s Agent). You want to switch the codes for the actual descriptions. In cell E12 of the Details sheet, insert the SWITCH function to evaluate the agent code in cell D12. Include mixed cell references to the codes and roles in the range J2:K4 for the values and results arguments. use all cell references in the function. Copy the function to the range E13:E39. 5 3 Now you want to calculate the number of days between the list date and sale date. In cell J12, insert the DAYS function to calculate the numbe...
56
Views
0
Answers
C++ Friend Finder,The Person class will be used repeatedly when the roster is loaded into the Organization.
Proj2 zip has already made header files, proj2.cpp and sample txt that shouldn't be changed, CSMC202 project instructions were provided and should be followed....