-
Notifications
You must be signed in to change notification settings - Fork 0
/
car.go
76 lines (62 loc) · 1.35 KB
/
car.go
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"io"
)
//Car Structure
type Car struct {
Company string
Model string
Color string
Tires int
Mileage int
TopSpeed int
Years int
Output io.Writer
}
//NewCar created
func NewCar(output io.Writer) *Car {
return &Car{
Company: "Nissan",
Model: "Skyline GTR R34",
Color: "Black",
Tires: 0,
Mileage: 0,
TopSpeed: 160,
Years: 0,
Output: output,
}
}
//satisfies the car interface
//Age allows the car to get older
func (c *Car) Age() {
c.Years++
}
//Miles adds mileage to car
func (c *Car) Miles() {
c.Mileage++
}
//Drive makes the car drive
func (c *Car) Drive() {
c.Output.Write([]byte("Bruce goes for a drive....skinny pedal getting lit up<br>\n"))
c.Mileage = c.Mileage + 1000
}
//Oil changes the oil in the car
func (c *Car) Oil() {
c.Output.Write([]byte("Bruce gets the oil changed...keep it fresh broski<br>\n"))
c.Mileage = 0
}
//Park keeps the car parked
func (c *Car) Park() {
c.Output.Write([]byte("It is raining, ain't no way Bruce is driving this gem in that<br>\n"))
c.Mileage = c.Mileage + 1000
}
//Wash washes the Skyline
func (c *Car) Wash() {
c.Output.Write([]byte("Car is dirty, time for a scrub!<br>\n"))
c.Mileage = c.Mileage + 1000
}
//Drift the car
func (c *Car) Drift() {
c.Output.Write([]byte("Drift time....getting slidewayzzz<br>\n"))
c.Tires = c.Tires + 1
}