Question

Python: inheritance. Adding delta_x and delta_y to the 'Shape' class. Note that all other classes inherit...

Python: inheritance. Adding delta_x and delta_y to the 'Shape' class. Note that all other classes inherit from the shape class in this problem. It is the sixth function down. Instructions are on the right side of the screen. My code doesn't work so feel help please.

Homework Answers

Answer #1

This code would work. Read and understand it it's pretty simple.

class Shape(object):

def __init__(self, x, y):

self.x = x

self.y = y

class Square(Shape):

def __init__(self, side=1, x=0, y=0):

super(Square,self).__init__(x, y)

self.side = side

class Circle(Shape):

def __init__(self, rad=1, x=0, y=0):

super(Circle,self).__init__(x, y)

self.radius = rad

Now defining the method : as delta

def delta(self, delta_x, delta_y):

self.x += delta_x

self.y += delta_y

Adding this to Shape class:

@add_method(Shape)

def delta(self, delta_x, delta_y):

self.x += delta_x

self.y += delta_y

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Python recursive design question: Background: The class vote creates vote objects. A vote is either a...
Python recursive design question: Background: The class vote creates vote objects. A vote is either a blue vote, a red vote, or a purple. This information is stored in the "value" attribute. The function Poll returns a list of random votes. In the code below, some_poll is a list of 32 random votes. some_poll = Poll(32) # ----------------------------------------------------- import random # ----------------------------------------------------- # # Return a list of n random votes # # ----------------------------------------------------- def Poll(n=16): # # A random...
Note: Do not use classes or any variables of type string to complete this assignment Write...
Note: Do not use classes or any variables of type string to complete this assignment Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along...
Note: Please rewrites these all paragraphs in other words because this all plagiarized please make in...
Note: Please rewrites these all paragraphs in other words because this all plagiarized please make in different words . Article review The thesis under review is authored by Dr. James Ryan Reblando titled ‘School climate, instructors learning management and student’s self-efficacy’. This was a doctoral thesis published in 2018 in the International Journal of Advanced Research. The purpose of this doctoral thesis was to analyze the impact of school climate, learning management on the academic performances of students and answer...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size. The first inputs to the program will be the recipe itself. Here is an example recipe...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you start doing anything… This project involves implementing a simple university personnel management program. The program contains two different kinds of objects: students and faculty. For each object, the program stores relevant information such as university ID, name, etc. Different information is stored depending on the type of the object. For example, a student has a GPA, while a faculty has a title and department...
Challenge 5 Read ALL of the instructions carefully before starting the exercise! Dear Colleague, Earlier today...
Challenge 5 Read ALL of the instructions carefully before starting the exercise! Dear Colleague, Earlier today I built my fourth website using HTML5 and CSS3. This time I wanted to try using CSS float layout options on a website dedicated to my favorite topic: robotics. I wanted my website to look like what is shown in Figure 1 (see below). However, after giving it my best effort, things once again didn’t turn out the way I wanted (see the code...
Practice using EXCEL – Part of your Orientation Assignment to prepare for class on the first...
Practice using EXCEL – Part of your Orientation Assignment to prepare for class on the first day. Step by Step instructions on completing PR1-5B. BEFORE STARTING TO WORK THE PROBLEM YOU NEED TO WRITE ALL BALANCE FORMULAS. To do so do the following in order. Click on Cell D39. In D39 you will write a formula to add rows D37 and D38. To do so do the following: a)    Start in Cell D39 and press = sign b)    Highlight cell...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
Please check all my grammar, sentence structure, punctuation, transional words, verbs, topic sentences, etc. Please correct...
Please check all my grammar, sentence structure, punctuation, transional words, verbs, topic sentences, etc. Please correct like a strict teacher. Thank you very much for your help. There are few traits she looking for in the new leader and manager. She’s looking for people that open to learning, flexible, go above and beyond and learn to step outside their comfort zone no matter how difficult it may be. She wants people to take the initiative, she wants them to ask...
§ Comment your code - you will be glad you did. You will be reusing code...
§ Comment your code - you will be glad you did. You will be reusing code throughout the semester. § You will demo each of your projects. In each demo, you will be asked to demonstrate the functionality of the program and possibly describe how some of the code works. Be prepared for this. § You will upload your projects on Blackboard. Details about this will be announced in class. § Late projects will lose points: 20% per day of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT