Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ViewController.swift
- // quiz
- //
- // Created by 小嶋大貴 on 2015/02/19.
- // Copyright (c) 2015年 小嶋大貴. All rights reserved.
- //
- import UIKit
- class ViewController: UIViewController {
- @IBOutlet weak var label: UILabel!
- @IBOutlet weak var label2: UILabel!
- @IBOutlet weak var quiz: UITextView!
- @IBOutlet weak var upperbutton: UIButton!
- @IBOutlet weak var lowerbutton: UIButton!
- let upbutton = ["◯",
- "◯",
- "◯",
- "◯",
- "◯",
- ]
- let lowbutton = ["×",
- "×",
- "×",
- "×",
- "×",
- ]
- var todos = [ "富士山頂にある石を持って帰ると罪になる。",
- "世界一大きな湖はカスピ海である。",
- "シンガポールの首都はシンガポールである。",
- "日本からの訪問者が一番多いのは、韓国である。",
- "2014年世界大学学術ランキングの東京大学(21位)より上にランクインされている大学の国はアメリカとイギリスのみである。"
- ]
- var judge = [0,0,0,1,1]
- var count = 0
- @IBAction func before() {
- if count > 1 {
- count--
- }
- label.text = ("\(count)問目")
- quiz.text = ("\(todos [count - 1])")
- upperbutton.setTitle("\(upbutton[count - 1])" ,forState: .Normal)
- lowerbutton.setTitle("\(lowbutton[count - 1])" ,forState: .Normal)
- }
- @IBAction func next() {
- if count < 5 {
- count++
- }
- label.text = ("\(count)問目")
- quiz.text = ("\(todos[count - 1])")
- upperbutton.setTitle("\(upbutton[count - 1])" ,forState: .Normal)
- lowerbutton.setTitle("\(lowbutton[count - 1])" ,forState: .Normal)
- }
- @IBOutlet weak var num: UILabel!
- var no = 0
- var userAnsup = 0
- var userAnsdown = 1
- @IBAction func plus() {
- if judge[count-1] == userAnsup{
- label2.text = "正解です"
- no = no + 10
- }else{
- label2.text = "不正解です"
- no = no - 10
- }
- num.text = ("\(no)")
- }
- @IBAction func no1() {
- if judge[count-1] == userAnsdown{
- label2.text = "正解です"
- no = no + 10
- }else{
- label2.text = "不正解です"
- no = no - 10
- }
- num.text = ("\(no)")
- }
- 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.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement