Skip to content

Instantly share code, notes, and snippets.

@DmitryOlkhovoi
Created May 3, 2018 12:34
Show Gist options
  • Save DmitryOlkhovoi/27ceb95366b989adcbb23fd251d833d4 to your computer and use it in GitHub Desktop.
Save DmitryOlkhovoi/27ceb95366b989adcbb23fd251d833d4 to your computer and use it in GitHub Desktop.
Cars creator
//
// main.swift
// Cars creator
//
// Created by Dmitry Olkhovoi on 5/3/18.
// Copyright © 2018 Dmitry Olkhovoi. All rights reserved.
//
var cars = [String]()
var exit = false
print("Hello, type in a command:")
while !exit, let cmd = readLine() {
switch(cmd) {
case "add":
print("Type in a name of the car:")
cars.append(readLine()!)
case "show":
print(cars)
case "q":
exit = true
print("Bye!")
default:
print("Undefined command!")
}
print("Command:")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment