Adding More Translations
This commit is contained in:
parent
543bc78e51
commit
d96e315705
20
7 - Classes and Objects/Challenge/Ball.py
Normal file
20
7 - Classes and Objects/Challenge/Ball.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
class Ball():
|
||||||
|
def __init__(self, diameter, color):
|
||||||
|
self.diameter = diameter
|
||||||
|
self.color = color
|
||||||
|
self.timesBounced = 0
|
||||||
|
|
||||||
|
def getDiameter(self):
|
||||||
|
return self.diameter
|
||||||
|
|
||||||
|
def getColor(self):
|
||||||
|
return self.color
|
||||||
|
|
||||||
|
def getTimesBounced(self):
|
||||||
|
return self.timesBounced
|
||||||
|
|
||||||
|
def bounceBall(self):
|
||||||
|
self.timesBounced += 1
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "This ball is " + self.color + " with a diameter of " + str(self.diameter) + " and has been bounced " + str(self.timesBounced) + " times!"
|
22
7 - Classes and Objects/Challenge/README.md
Normal file
22
7 - Classes and Objects/Challenge/README.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Write a class called Ball with the following
|
||||||
|
- Characteristics
|
||||||
|
- diameter (float)
|
||||||
|
- color (string)
|
||||||
|
- timesBounced (int)
|
||||||
|
- Behaviors
|
||||||
|
- bounceBall
|
||||||
|
- getDiameter
|
||||||
|
- getColor
|
||||||
|
- getTimesBounced
|
||||||
|
|
||||||
|
Create 2 Balls
|
||||||
|
- Ball 1
|
||||||
|
- Diameter: .5
|
||||||
|
- Color: Red
|
||||||
|
- Bounce the ball 10 times
|
||||||
|
- Ball 2
|
||||||
|
- Diameter: 1
|
||||||
|
- Color: Yellow
|
||||||
|
- Bounce teh ball 1 time
|
||||||
|
|
||||||
|
Print all the values for both balls
|
12
7 - Classes and Objects/Challenge/main.py
Normal file
12
7 - Classes and Objects/Challenge/main.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import Ball
|
||||||
|
|
||||||
|
ball1 = Ball.Ball(5, "Red")
|
||||||
|
ball2 = Ball.Ball(1, "Yellow")
|
||||||
|
|
||||||
|
for i in range(10):
|
||||||
|
ball1.bounceBall()
|
||||||
|
|
||||||
|
ball2.bounceBall()
|
||||||
|
|
||||||
|
print(ball1)
|
||||||
|
print(ball2)
|
0
7 - Classes and Objects/README.md
Normal file
0
7 - Classes and Objects/README.md
Normal file
21
7 - Classes and Objects/Tree.py
Normal file
21
7 - Classes and Objects/Tree.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
class Tree():
|
||||||
|
def __init__(self, typeOfTree, height, width):
|
||||||
|
self.typeOfTree = typeOfTree
|
||||||
|
self.height = height
|
||||||
|
self.width = width
|
||||||
|
|
||||||
|
def getTypeOfTree(self):
|
||||||
|
return self.typeOfTree
|
||||||
|
|
||||||
|
def getHeight(self):
|
||||||
|
return self.height
|
||||||
|
|
||||||
|
def getWidth(self):
|
||||||
|
return self.width
|
||||||
|
|
||||||
|
def grow(self, heightAdd, widthAdd):
|
||||||
|
self.height += heightAdd
|
||||||
|
self.width += widthAdd
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Type of Tree: " + self.typeOfTree + " Height: " + str(self.height) + " Width: " + str(self.width)
|
10
7 - Classes and Objects/main.py
Normal file
10
7 - Classes and Objects/main.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import Tree
|
||||||
|
|
||||||
|
oakTree = Tree.Tree("Oak", 10, .5)
|
||||||
|
pineTree = Tree.Tree("Pine", 25, 1.25)
|
||||||
|
|
||||||
|
print(oakTree)
|
||||||
|
oakTree.grow(5, .5)
|
||||||
|
|
||||||
|
print(oakTree)
|
||||||
|
print(pineTree)
|
BIN
8 - Basic Robot Electronics/CS8 - Basic Robot Electronics.odp
Normal file
BIN
8 - Basic Robot Electronics/CS8 - Basic Robot Electronics.odp
Normal file
Binary file not shown.
BIN
8 - Basic Robot Electronics/CS8 - Basic Robot Electronics.pdf
Normal file
BIN
8 - Basic Robot Electronics/CS8 - Basic Robot Electronics.pdf
Normal file
Binary file not shown.
0
8 - Basic Robot Electronics/README.md
Normal file
0
8 - Basic Robot Electronics/README.md
Normal file
Loading…
Reference in New Issue
Block a user