Skip to content

Instantly share code, notes, and snippets.

@NghiaTranUIT
Last active April 27, 2018 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NghiaTranUIT/a896d93609905b1aa0885c6cc22249e9 to your computer and use it in GitHub Desktop.
Save NghiaTranUIT/a896d93609905b1aa0885c6cc22249e9 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
struct VehicleCheck {
let sections: [Section]
}
struct Section {
enum Kind: String {
case general
case outside
case incab
}
let id: String
let kind: Kind
let name: String
let subSections: [SubSection]
}
struct SubSection {
enum Kind: String {
case vehicle
case trailer
case general
}
let kind: Kind
let id: String
let name: String
let attributes: [Attribute]
}
struct Attribute {
enum Status: String {
case yes
case no
case notSelect
}
let id: String
let name: String
let status: Status
let key: String
}
// General
if true {
let attribute_1 = Attribute(id: "1", name: "Have you put your Tacho on other work?", status: Attribute.Status.notSelect, key: "tacho")
let attribute_2 = Attribute(id: "2", name: "Vehicle registration: Vehicle Registration (Type)?", status: Attribute.Status.notSelect, key: "vehicle_registration")
let attribute_3 = Attribute(id: "3", name: "Trailer registration: Trailer Registration (Type)", status: Attribute.Status.notSelect, key: "trailer_registration")
let general = SubSection(kind: SubSection.Kind.general, id: 1, name: "General", attributes: [attribute_1, attribute_2, attribute_3])
// Final
let section_general = Section(id: "1", type: Section.Kind.general, name: "General", subSections: [general])
}
// Out side
// Has both Vehicle and Trailer as sub-section
if true {
let attribute_vehicle_1 = Attribute(id: "1", name: "Lights and indicators", status: Attribute.Status.notSelect, key: "lights_indicators")
let attribute_vehicle_2 = Attribute(id: "2", name: "Fuel/Oil Leaks", status: Attribute.Status.notSelect, key: "fuel_oil")
let attribute_trailer_1 = Attribute(id: "3", name: "Reflectors)", status: Attribute.Status.notSelect, key: "reflectors")
let attribute_trailer_2 = Attribute(id: "4", name: "Doors and exits)", status: Attribute.Status.notSelect, key: "doors_exits")
let vehicle = SubSection(kind: SubSection.Kind.vehicle, id: "1", name: "Vehicle", attributes: [attribute_vehicle_1, attribute_vehicle_2])
let trailer = SubSection(kind: SubSection.Kind.trailer, id: "2", name: "Trailer", attributes: [attribute_trailer_1, attribute_trailer_2])
// Final
let section_Outside = Section(id: "2", kind: Section.Kind.outside, name: "Outside", subSections: [vehicle, trailer])
}
// Out side
// Has ONLY Vehicle as sub-section
if true {
let attribute_vehicle_1 = Attribute(id: "1", name: "Lights and indicators", status: Attribute.Status.notSelect, key: "lights_indicators")
let attribute_vehicle_2 = Attribute(id: "2", name: "Fuel/Oil Leaks", status: Attribute.Status.notSelect, key: "fuel_oil")
let vehicle = SubSection(kind: SubSection.Kind.vehicle, id: "1", name: "Vehicle", attributes: [attribute_vehicle_1, attribute_vehicle_2])
// Final
let section_Outside = Section(id: "2", kind: Section.Kind.outside, name: "Outside", subSections: [vehicle])
}
// Inside
// Has both Vehicle and Trailer as sub-section
if true {
let attribute_vehicle_1 = Attribute(id: "1", name: "Mirrors and glass", status: Attribute.Status.notSelect, key: "mirrors_glass")
let attribute_vehicle_2 = Attribute(id: "2", name: "Brakes", status: Attribute.Status.notSelect, key: "brakes")
let attribute_trailer_1 = Attribute(id: "3", name: "Seat and Seatbelt)", status: Attribute.Status.notSelect, key: "seat_seatbelt")
let attribute_trailer_2 = Attribute(id: "4", name: "Warning Lamp)", status: Attribute.Status.notSelect, key: "doors_exits")
let vehicle = SubSection(kind: SubSection.Kind.vehicle, id: "1", name: "Vehicle", attributes: [attribute_vehicle_1, attribute_vehicle_2])
let trailer = SubSection(kind: SubSection.Kind.trailer, id: "2", name: "Trailer", attributes: [attribute_trailer_1, attribute_trailer_2])
// Final
let section_inside = Section(id: "2", kind: Section.Kind.incab, name: "Inside", subSections: [vehicle, trailer])
}
// Response
let vehicleCheck = VehicleCheck(sections: [section_general, section_Outside, section_inside])
let response = vehicleCheck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment