Tuesday, November 14, 2017

Week 13 Swift Demo

IBM Swift Sandbox, online Swift compiler and execution
//Here is one of the two temp convert classes that you will need
//CtoF Class example
import Foundation

class CtoF {
    var temp = 0.0
  
    init(temp: Double) { // Constructor
        self.temp = temp
      
    }
  var Temp: Double{
  return (temp*(9/5)) + 32
  }

  func getTemp() -> Double {
    return (temp*(9/5)) + 32
  }
}

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
    }
}

////
let temp1 = CtoF(temp: 0.0)
print("Celsius to Fahrenheit temperature:",temp1.getTemp())       // access the function
print(temp1.Temp);             //access the Property

///
let circ1 = Circle(radius: 32.0)
print("Area:",circ1.getArea())
print("Circumference: ",circ1.getCircumference())

Tuesday, February 14, 2017

Chapter 6 Array Demo

Step 1) Right click then save content.
Step 2) Open in NotePad++
Step 3) Run->choose browser
Loop Demo