Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. //
  2. // ViewController.swift
  3. // quiz
  4. //
  5. // Created by 小嶋大貴 on 2015/02/19.
  6. // Copyright (c) 2015年 小嶋大貴. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. class ViewController: UIViewController {
  12.  
  13. @IBOutlet weak var label: UILabel!
  14.  
  15. @IBOutlet weak var label2: UILabel!
  16.  
  17. @IBOutlet weak var quiz: UITextView!
  18.  
  19. @IBOutlet weak var upperbutton: UIButton!
  20.  
  21. @IBOutlet weak var lowerbutton: UIButton!
  22.  
  23. let upbutton = ["◯",
  24. "◯",
  25. "◯",
  26. "◯",
  27. "◯",
  28. ]
  29.  
  30.  
  31. let lowbutton = ["×",
  32. "×",
  33. "×",
  34. "×",
  35. "×",
  36.  
  37. ]
  38.  
  39.  
  40.  
  41. var todos = [ "富士山頂にある石を持って帰ると罪になる。",
  42. "世界一大きな湖はカスピ海である。",
  43. "シンガポールの首都はシンガポールである。",
  44. "日本からの訪問者が一番多いのは、韓国である。",
  45. "2014年世界大学学術ランキングの東京大学(21位)より上にランクインされている大学の国はアメリカとイギリスのみである。"
  46. ]
  47.  
  48. var judge = [0,0,0,1,1]
  49.  
  50. var count = 0
  51.  
  52. @IBAction func before() {
  53. if count > 1 {
  54. count--
  55.  
  56. }
  57. label.text = ("\(count)問目")
  58.  
  59. quiz.text = ("\(todos [count - 1])")
  60.  
  61. upperbutton.setTitle("\(upbutton[count - 1])" ,forState: .Normal)
  62.  
  63. lowerbutton.setTitle("\(lowbutton[count - 1])" ,forState: .Normal)
  64. }
  65.  
  66.  
  67. @IBAction func next() {
  68.  
  69.  
  70. if count < 5 {
  71. count++
  72.  
  73. }
  74. label.text = ("\(count)問目")
  75.  
  76.  
  77.  
  78. quiz.text = ("\(todos[count - 1])")
  79.  
  80. upperbutton.setTitle("\(upbutton[count - 1])" ,forState: .Normal)
  81.  
  82. lowerbutton.setTitle("\(lowbutton[count - 1])" ,forState: .Normal)
  83.  
  84.  
  85. }
  86.  
  87.  
  88.  
  89.  
  90.  
  91. @IBOutlet weak var num: UILabel!
  92.  
  93. var no = 0
  94.  
  95.  
  96.  
  97. var userAnsup = 0
  98.  
  99. var userAnsdown = 1
  100.  
  101.  
  102. @IBAction func plus() {
  103. if judge[count-1] == userAnsup{
  104.  
  105. label2.text = "正解です"
  106. no = no + 10
  107. }else{
  108. label2.text = "不正解です"
  109. no = no - 10
  110. }
  111.  
  112.  
  113.  
  114.  
  115. num.text = ("\(no)")
  116.  
  117.  
  118. }
  119.  
  120.  
  121. @IBAction func no1() {
  122.  
  123. if judge[count-1] == userAnsdown{
  124. label2.text = "正解です"
  125. no = no + 10
  126. }else{
  127. label2.text = "不正解です"
  128. no = no - 10
  129. }
  130.  
  131.  
  132. num.text = ("\(no)")
  133.  
  134. }
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144. override func viewDidLoad() {
  145. super.viewDidLoad()
  146. // Do any additional setup after loading the view, typically from a nib.
  147. }
  148.  
  149. override func didReceiveMemoryWarning() {
  150. super.didReceiveMemoryWarning()
  151. // Dispose of any resources that can be recreated.
  152. }
  153.  
  154.  
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement