Skip to content

Instantly share code, notes, and snippets.

@djgoldsmith
Created May 14, 2018 03:37
Show Gist options
  • Save djgoldsmith/5bfa8d31e002e8c2c51778a8c1ca0c99 to your computer and use it in GitHub Desktop.
Save djgoldsmith/5bfa8d31e002e8c2c51778a8c1ca0c99 to your computer and use it in GitHub Desktop.
class Circle {
var radius : Double
init(theradius: Double) {
//Update classes radius value with the one provided
radius = theradius
}
func getArea() -> Double {
//Calculate the area of the circle
return 3.14 * (radius * radius)
}
//Add a Function to Caluclate the Circumference (Pi * R * R)
func getCircumference()
{
//Code Goes Here
}
//List of Circles
var theList = [2.0,4.0,6.0]
for item in theList {
//New Circle
var theCircle = Circle(theradius: item)
//Print
print ("Circle of Radius: \(item)")
print ("\tArea: \(theCircle.getArea())")
print ("\tCircum: \(theCircle.getCircumference())")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment