import Foundation
struct Coord {
var x: Double
var y: Double
func movida(incX: Double, incY: Double) -> Coord {
return Coord(x: x+incX, y: y+incY)
}
mutating func mueve(incX: Double, incY: Double) {
x = x + incX
y = y + incY
}
}
struct Cuadrado {
var esquina = Coord(x: 0.0, y: 0.0)
var lado: Double
func movido1(incx : Double, incy : Double) -> Cuadrado{
let nuevaesquina = movida(incX :incx, incY: incy);
return Cuadrado(esquina: nuevaesquina, lado : lado)
}
func movido2(incx: Double, incy: Double)-> Cuadrado {
var nuevaesquina = esquina
nuevaesquina = mueve(incX: incx, incY: incy)
return Cuadrado(esquina: nuevaesquina, lado : lado)
}
mutating func mueve(incx: Double, incy: Double){
esquina.mueve(incX: incx, incY, incy)
}
}
struct Punto{
var x = 0.0, y :0.0
}
To embed this project on your website, copy the following code and paste it into your website's HTML: