Skip to content

Instantly share code, notes, and snippets.

@shabib87
Last active February 25, 2017 08:48
Show Gist options
  • Save shabib87/800edca06d1dd088ede4e923a3cb0821 to your computer and use it in GitHub Desktop.
Save shabib87/800edca06d1dd088ede4e923a3cb0821 to your computer and use it in GitHub Desktop.
enum BiriyaniType {
case veg
case nonveg
}
class Biriyani {
let count: Int
let size: OrderSize
let spiceRange: SpiceRange
let type: BiriyaniType
init (count: Int, size: OrderSize, spiceRange: SpiceRange, type: BiriyaniType) {
self.count = count
self.size = size
self.spiceRange = spiceRange
self.type = type
}
convenience init(size: OrderSize, spiceRange: SpiceRange, type: BiriyaniType) {
self.init(count: 1, size: size, spiceRange: spiceRange, type: type)
}
convenience init(spiceRange: SpiceRange, type: BiriyaniType) {
self.init(count: 1, size: .medium, spiceRange: spiceRange, type: type)
}
convenience init(spiceRange: SpiceRange) {
self.init(count: 1, size: .medium, spiceRange: spiceRange, type: .nonveg)
}
convenience init(type: BiriyaniType) {
self.init(count: 1, size: .medium, spiceRange: .spicy, type: type)
}
}
class Restaurant {
var biriyaniOrder1 = Biriyani(size: .medium, spiceRange: .hot, type: .veg)
var biriyaniOrder2 = Biriyani(spiceRange: .extraHot, type: .veg)
var biriyaniOrder3 = Biriyani(spiceRange: .extraHot)
var biriyaniOrder4 = Biriyani(type: .veg)
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment