Circle on Repl.it
This is for use on iOS using XCode
// Declare our new Circle class
class Circle {
var radius = 0.0
init(radius: Double) { // Constructor
self.radius = radius
}
var Area: Double{
return 3.14*(radius*radius)
}
func getArea() -> Double {
return 3.14*(radius*radius)
}
var Circumference: Double {
return 2*3.14*radius
}
func getCircumference() -> Double{
return 2*3.14*radius
}
}
@IBAction func btnCalc(_ sender: UIButton) {
let rad=Double(tbRad.text!);
let circ1=Circle(radius:rad!);
let a=String(format: "%.2f",circ1.getArea());
let c=circ1.getCircumference();
lblArea.text="Area: \(a)";
lblCirc.text="Circumfrence: \(c)";
}
Thanks for your great information, the contents are quiet interesting. I will be waiting for your next post.
ReplyDeleteMobile App Development.