Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

poolball 2 Rutgers University PYTHON 101

Rating
-
Sold
-
Pages
2
Uploaded on
08-04-2023
Written in
2022/2023

####### Karthik Kuchimanchi ####### Unit Five Assignment One ####### Pool Ball Appilication ######## Karthik Kuchimanhi ######## Unit Five Assignment One ######## Pool Ball Representation from math import sqrt class ball: #### Constructor which accepts 4 variables and self) def __init__(self,number,color,isStriped,location): r = number = color Striped = isStriped ion = [0,0] #### loop to set parameters of location[0] if location[0] = 0 and location[0] = 1: ion[0] = location[0] else: ion[0] = 0.5 #### loop to set parameter of location[1] if location[1] = 0 and location[1] = 2: ion[1] = location[1] else: ion[1] = 0.5 #### method #1: Distance - Find the distance of a ball to the coordinates given #### sqrt((y1-y2)^2 + (x1-x2)^2) def Distance(self,x2,y2): x1 = ion[0] y1 = ion[1] return sqrt((y1-y2) ** 2 + (x1-x2) ** 2) #### method #2: Set the location of a ball to the coordinates given. This function should also check #### if the coordinates given are out of bounds or not and do nothing if the given coordinates are. def setLo

Show more Read less
Institution
Course

Content preview

####### Karthik Kuchimanchi
####### Unit Five Assignment One
####### Pool Ball Appilication

######## Karthik Kuchimanhi
######## Unit Five Assignment One
######## Pool Ball Representation

from math import sqrt

class ball:

#### Constructor which accepts 4 variables and self)
def __init__(self,number,color,isStriped,location):
self.number = number
self.color = color
self.isStriped = isStriped
self.location = [0,0]

#### loop to set parameters of location[0]
if location[0] >= 0 and location[0] <= 1:
self.location[0] = location[0]
else:
self.location[0] = 0.5

#### loop to set parameter of location[1]
if location[1] >= 0 and location[1] <= 2:
self.location[1] = location[1]
else:
self.location[1] = 0.5

#### method #1: Distance - Find the distance of a ball to the coordinates given
#### sqrt((y1-y2)^2 + (x1-x2)^2)

def Distance(self,x2,y2):
x1 = self.location[0]
y1 = self.location[1]
return sqrt((y1-y2) ** 2 + (x1-x2) ** 2)

#### method #2: Set the location of a ball to the coordinates given. This
function should also check
#### if the coordinates given are out of bounds or not and do nothing if the
given coordinates are.

def setLocation(self, newLocation):

#### loop to set parameters of newLocation[0]
if newLocation[0] >= 0 and newLocation[0] <= 1:
self.location[0] = newLocation[0]
else:
self.location[0] = 0.5

#### loop to set parameters of newLocation[1]
if newLocation[1] >= 1 and newLocation[1] <= 2:
self.location[1] = newLocation[1]
else:
self.location[1] = 0.5

#### output method


This study source was downloaded by 100000850872992 from CourseHero.com on 04-08-2023 16:39:32 GMT -05:00


https://www.coursehero.com/file/134525719/poolball2py/

Written for

Course

Document information

Uploaded on
April 8, 2023
Number of pages
2
Written in
2022/2023
Type
OTHER
Person
Unknown

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ExamsConnoisseur Self
Follow You need to be logged in order to follow users or courses
Sold
587
Member since
3 year
Number of followers
344
Documents
1492
Last sold
1 week ago

4.2

68 reviews

5
40
4
11
3
13
2
1
1
3

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions