//
func sumOf(numbers:Int...)->Int{
var sum=0
for number in numbers {
sum+=number
}
return sum
}
sumOf()
sumOf(4,5,12)
//
func returnFifteen()-> Int{
var y=0
func add(){
y+=15
}
add()
return y
}
returnFifteen()
/////
////
class Shape{
var numberOfSides=0
func simpleDescription() -> String{
return "A shape with \(numberOfSides)"
}
}
var shape = Shape()
shape.numberOfSides = 7
var shapedescripton=shape.simpleDescription();
class NameShape{
var numberOfSides:Int=0
var name:String
init (name:String)
{
self.name=name
}
func simpleDescription ()->String
{
return "A shape with \(numberOfSides) sides."
}
}
class Square:NameShape{
var sideLength:Double
init(sideLength:Double ,name :String){
self.sideLength=sideLength
super.init(name: name)
numberOfSides=8
}
func area()->Double{
return sideLength * sideLength
}
override func simpleDescription() -> String {
return "A square with sides of length \(sideLength)"
}
}
let test = Square(sideLength: 5, name: "my test square")
test.area()
test.simpleDescription()