-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathPokedex.swift
56 lines (43 loc) · 1.48 KB
/
Pokedex.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Pokdex (Sonny Li)
class Pokemon {
var num = 0
var name = ""
var type = [""]
var ability = [""]
init(num: Int, name: String, type: [String], ability: [String]) {
self.num = num
self.name = name
self.type = type
self.ability = ability
}
func displayInfo() {
print("No. #\(num)")
print("Name \(name)")
print("Type \(type)")
print("Abilities \(ability)")
print("===================================")
}
}
class GigantamaxPokemon: Pokemon {
var location = ""
init(num: Int, name: String, type: [String], ability: [String], location: String) {
self.location = location
super.init(num: num, name: name, type: type, ability: ability)
}
override func displayInfo() {
print("No. #\(num)")
print("Name \(name)")
print("Type \(type)")
print("Abilities \(ability)")
print("Location \(location)")
print("===================================")
}
}
var bulbasaur = Pokemon(num: 1, name: "Bulbasaur", type: ["Grass 🌱", "Poison 💀"], ability: ["Overgrow"])
var charmander = Pokemon(num: 4, name: "Charmander", type: ["Fire 🔥"], ability: ["Blaze"])
var squirtle = Pokemon(num: 7, name: "Squirtle", type: ["Water 💧"], ability: ["Torrent"])
var charizard = GigantamaxPokemon(num: 6, name: "Charizard", type: ["Fire 🔥"], ability: ["Blaze"], location: "Lake of Outrage")
bulbasaur.displayInfo()
charmander.displayInfo()
squirtle.displayInfo()
charizard.displayInfo()