logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

In this assignment, you'll create a program that combines modules and classes. The classes will be created in separate files, shape.py and circle.py.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

1.  Reading and Study

Week 4's's's reading

How to write code to test your modules Before you start writing your program:

Study and understand the Shape class described on page 33.

Study and understand the Circle class described on in section 15.5.2 (p. 215).

super()

Lab files

Download The Shape and Circle modules designed for this assignment. These modules are modifications of the Circle and Shape classes shown in The Quick Python Book/These two files have a /.txt file extension that you'll have to remove to make them .py files.

In this assignment, you'll create a program names lab4.1.py that combines modules and classes. The classes will be created in separate files, shape.py and circle.py. To complete this problem you will be writing several methods in the shape.py and circle.py.

The final exam will contain a question about classes and modules

When you write lab4.1.py, you will import the Shape and Circle classes into your program. Your lab4.1.py program will generate plain text output that is organized and readable by the grader (me!).

Summary

lab4.1.py uses two classes, Shape and Circle. The Circle class is a subclass of
Shape.
The shape.py file is a module that contains the Shape class, the parent class of geometric shapes such as Circle.
The circle.py file is a module that contains the Circle class, which is a subclass of
Shape. As a subclass, Circle must import shape.py.

lab4.1.py will:

Import the shape.py and circle.py modules. Create two Circle objects.
Move the two circle objects around the x,y co-ordinate system by changing their x and y
coordinates.
Determine whether the circles overlap, or "collide" with each other. "Collide", in this assignments, means that the two circles occupy the same point at the same time. That is to say, if the two circles intersect, they are colliding. This faux animated example will help you visualize how your script will generate a series of circles and report whether they are colliding. This example is really a series of HTTP requests, one for each movement of the two circles.

Example output

Your script should display your program's data as well-formatted, readable, human-friendly plain text, as in the plain text example below. If you're feeling ambitious, you might want to try writing a CGI script that will format the output using HTML.

Your script should create plain text output.

Plain text output of lab4.1.py

TODO Complete the shape.py module

Download shape.py

The Shape class in shape.py is almost complete. The location() method needs to be completed. You'll see it indicated like this.

########################################## # TODO TODO TODO --- COMPLETE THIS METHOD ##########################################

def location(self):

'''Returns a tuple containing the (x,y) coordinates of a Shape object

When writing your code, you have to replace "pass" with your code.''' pass

init (), a class constructor what sets an objects x,y coordinates. Completed

move(), a method to move objects to new x,y coordinates. Completed                                                                                       

location(), a method that returns a tuple containing an object x,y coordinates. You have to complete this method. This method will be inherited by any subclasses.

The Shape class provides methods to set a shape's x,y coordinates, to move the shape to a new set of coordinates, and to report the shape's location as a tuple containing the object's x,y coordinates. You have to complete the location() method.

Here's some code to get you started on shape.py. It's based on the source code for the Shape

class on p. 30 of The Quick Python Book.

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

582 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

729 Answers

Hire Me
expert
Husnain SaeedComputer science

885 Answers

Hire Me
expert
Atharva PatilComputer science

585 Answers

Hire Me