Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum lamp:CustomStringConvertible
- {
- case A,B,C,D,E,F
- func getValue()->Int{
- let fu:Int=self.hashValue
- switch fu {
- case lamp.A.hashValue:
- return (10)
- case lamp.B.hashValue:
- return (45)
- case lamp.C.hashValue:
- return (75)
- case lamp.D.hashValue:
- return (100)
- case lamp.E.hashValue:
- return (125)
- case lamp.F.hashValue:
- return (150)
- default:
- return (0)
- }
- }
- var description: String{
- let fu:Int=self.hashValue
- switch fu {
- case lamp.A.hashValue:
- return ("you have 25W")
- case lamp.B.hashValue:
- return ("you have 40W")
- case lamp.C.hashValue:
- return ("you have 60W")
- case lamp.D.hashValue:
- return ("you have 75W")
- case lamp.E.hashValue:
- return ("you have 100W")
- case lamp.F.hashValue:
- return ("you have 125W")
- default:
- return ("you dont have lamp....")
- }
- }
- }
- var myLamp:lamp = .A
- print(myLamp)
- //print(myLamp.getValue())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement