<commit_before>//
//  ViewController.swift
//  LemonadeStand
//
//  Created by <NAME> on 1/11/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

  @IBOutlet weak var balanceLabel: UILabel!
  @IBOutlet weak var lemonTotalLabel: UILabel!
  @IBOutlet weak var iceCubeTotalLabel: UILabel!
  @IBOutlet weak var lemonPurchaseLabel: UILabel!
  @IBOutlet weak var iceCubePurchaseLabel: UILabel!
  @IBOutlet weak var lemonMixLabel: UILabel!
  @IBOutlet weak var iceCubeMixLabel: UILabel!
  
  @IBOutlet weak var lemonPurchaseStepper: UIStepper!
  @IBOutlet weak var iceCubePurchaseStepper: UIStepper!
  @IBOutlet weak var lemonMixStepper: UIStepper!
  @IBOutlet weak var iceCubeMixStepper: UIStepper!
  
  var supplies = Supplies(money: 10, lemons: 1, iceCubes: 1)
  var price = Price()
  
  var lemonsToPurchase = 0
  var iceCubesToPurchase = 0
  var lemonsToMix = 0
  var iceCubesToMix = 0
  
  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    updateMainView()
  }
  
  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }
  
  @IBAction func lemonPurchaseValueChanged(sender: UIStepper) {
    if lemonsToPurchase > Int(lemonPurchaseStepper.value) {
      //println("subtracting")
      supplies.money += price.lemon
      supplies.lemons -= 1
    }
    else {
      //println("adding")
      if supplies.money >= price.lemon {
        supplies.money -= price.lemon
        supplies.lemons += 1
        
      } else {
        lemonPurchaseStepper.value -= 1
        lemonPurchaseStepper.maximumValue = lemonPurchaseStepper.value
        //showAlertWithText(message:"You don't have enough money")
      }
    }
    
    lemonsToPurchase = Int(lemonPurchaseStepper.value)
    updateMainView()
  }
  
  @IBAction func iceCubePurchaseValueChanged(sender: UIStepper) {
    iceCubesToPurchase = Int(iceCubePurchaseStepper.value)
    updateMainView()
  }
  
  @IBAction func lemonMixValueChanged(sender: UIStepper) {
    lemonsToMix = Int(lemonMixStepper.value)
    updateMainView()
  }
  
  @IBAction func iceCubeMixValueChange(sender: UIStepper) {
    iceCubesToMix = Int(iceCubeMixStepper.value)
    updateMainView()
  }
  
  func updateMainView() {
    balanceLabel.text = "$\(supplies.money)"
    lemonTotalLabel.text = "\(supplies.lemons) Lemons"
    iceCubeTotalLabel.text = "\(supplies.iceCubes) Ice Cubes"
    <commit_msg>Note to future self<commit_after>//
//  ViewController.swift
//  LemonadeStand
//
//  Created by <NAME> on 1/11/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

  @IBOutlet weak var balanceLabel: UILabel!
  @IBOutlet weak var lemonTotalLabel: UILabel!
  @IBOutlet weak var iceCubeTotalLabel: UILabel!
  @IBOutlet weak var lemonPurchaseLabel: UILabel!
  @IBOutlet weak var iceCubePurchaseLabel: UILabel!
  @IBOutlet weak var lemonMixLabel: UILabel!
  @IBOutlet weak var iceCubeMixLabel: UILabel!
  
  @IBOutlet weak var lemonPurchaseStepper: UIStepper!
  @IBOutlet weak var iceCubePurchaseStepper: UIStepper!
  @IBOutlet weak var lemonMixStepper: UIStepper!
  @IBOutlet weak var iceCubeMixStepper: UIStepper!
  
  var supplies = Supplies(money: 10, lemons: 1, iceCubes: 1)
  var price = Price()
  
  var lemonsToPurchase = 0
  var iceCubesToPurchase = 0
  var lemonsToMix = 0
  var iceCubesToMix = 0
  
  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    updateMainView()
  }
  
  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }
  
  @IBAction func lemonPurchaseValueChanged(sender: UIStepper) {
    if lemonsToPurchase > Int(lemonPurchaseStepper.value) {
      //println("subtracting")
      supplies.money += price.lemon
      supplies.lemons -= 1
    }
    else {
      //println("adding")
      if supplies.money >= price.lemon {
        supplies.money -= price.lemon
        supplies.lemons += 1
        
      } else {
        // Do this "else" check after updateMainView?
        lemonPurchaseStepper.value -= 1
        lemonPurchaseStepper.maximumValue = lemonPurchaseStepper.value
        //showAlertWithText(message:"You don't have enough money")
      }
    }
    
    lemonsToPurchase = Int(lemonPurchaseStepper.value)
    updateMainView()
  }
  
  @IBAction func iceCubePurchaseValueChanged(sender: UIStepper) {
    iceCubesToPurchase = Int(iceCubePurchaseStepper.value)
    updateMainView()
  }
  
  @IBAction func lemonMixValueChanged(sender: UIStepper) {
    lemonsToMix = Int(lemonMixStepper.value)
    updateMainView()
  }
  
  @IBAction func iceCubeMixValueChange(sender: UIStepper) {
    iceCubesToMix = Int(iceCubeMixStepper.value)
    updateMainView()
  }
  
  func updateMainView() {
    balanceLabel.text = "$\(supplies.money)"
    lemonTotalLabel.text = "\(supplies.lemons) Lemons"
    iceCubeTotalLabel.text = "\(supplies.iceCubes) Ice Cubes"
    
{'fraction_non_alphanumeric': 0.09156020131629888, 'fraction_numerical': 0.007742934572202865, 'mean_word_length': 3.352990732940185, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1863747', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1731, 'n_words': 395}