----- CAPITULO 7 -------


Ejercicio numero 1

Codigo de Ejercicio:

  • Agregar Boton AM y FM a apliacion Radio estacion
  • 
    //
    //  ViewController.swift
    //  RadioStations
    
    //Jehovani de Jesus Chavez Segovia 2561842011
    
    //Radio estacion agregar boton am fm y mostrar diferentes frecuencias
    
    import UIKit
    
    class ViewController: UIViewController {
    
        var myStation: RadioStation
        var myStation2: RadioStation
        
        @IBOutlet var stationName : UILabel!
             @IBOutlet var stationFrequency : UILabel!
        @IBOutlet var stationBand : UILabel!
        
        required init(coder aDecoder: NSCoder) {
            
            myStation = RadioStation()
            myStation.frequency=105.5
            myStation.name = "Knix"
            myStation2 = RadioStation()
            myStation2.frequency=580.0
            myStation2.name = "Knix2"
            
            super.init(coder: aDecoder)
        }
        
            override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    
        @IBAction func buttonClick(sender: AnyObject) {
            stationName.text = myStation.name
            stationFrequency.text = String(format:"%f", myStation.frequency)
            
            if myStation.frequency >= RadioStation.minFMFrequency() && myStation.frequency <= RadioStation.maxFMFrequency() {
                stationBand.text = "FM"
            } else {
                stationBand.text = "AM"
            }
            
        }
    
        
        @IBAction func buttonClick2(sender: AnyObject) {
            stationName.text = myStation2.name
            stationFrequency.text = String(format:"%f", myStation2.frequency)
            
            if myStation2.frequency <= RadioStation.minAMFrequency() && myStation2.frequency >= RadioStation.maxAMFrequency() {
                stationBand.text = "FM"
            } else {
                stationBand.text = "AM"
            }
            
        }
    
        
        
        
    }
    
    
    
                                

Corriendo aplicacion

seleccionamos boton FM

seleccionamos boton AM