-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconverter.go
177 lines (153 loc) · 3.44 KB
/
converter.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package main
import (
"fmt"
"math"
)
//Converter : Struct for Converter
type Converter struct {
}
//type Named Types
type (
Feet float64
Cm float64
Min float64
Sec float64
MilSec float64
Cel float64
Fah float64
Rad float64
Deg float64
Kg float64
Pound float64
Km float64
Mile float64
Stone float64
Cal float64
Joule float64
Newton float64
)
//CentToFeet Coverter
func (conv Converter) CentToFeet(cm Cm) Feet {
var res = Feet(cm / 100.48)
return res
}
//FeetToCent Coverter
func (conv Converter) FeetToCent(feet Feet) Cm {
var res = Cm(feet * 100.48)
return res
}
//MinToSec Coverter
func (conv Converter) MinToSec(min Min) Sec {
var res = Sec(min * 60)
return res
}
//SecToMin Coverter
func (conv Converter) SecToMin(sec Sec) Min {
var res = Min(sec / 60)
return res
}
//SecToMilSec Coverter
func (conv Converter) SecToMilSec(sec Sec) MilSec {
var res = MilSec(sec * 1000)
return res
}
//MilSecToSec Coverter
func (conv Converter) MilSecToSec(milSec MilSec) Sec {
var res = Sec(milSec / 1000)
return res
}
//CelToFah Coverter
func (conv Converter) CelToFah(cel Cel) Fah {
var res = Fah((cel * 9 / 5) + 32)
return res
}
//FahToCel Coverter
func (conv Converter) FahToCel(fah Fah) Cel {
var res = Cel((fah - 32) * 5 / 9)
return res
}
//RadToDeg Coverter
func (conv Converter) RadToDeg(rad Rad) Deg {
var res = Deg(rad * 180 / math.Pi)
return res
}
//DegToRad Coverter
func (conv Converter) DegToRad(deg Deg) Rad {
var res = Rad(deg * math.Pi / 180)
return res
}
//KgToPound Coverter
func (conv Converter) KgToPound(kg Kg) Pound {
var res = Pound(kg * 2.205)
return res
}
//PoundToKg Coverter
func (conv Converter) PoundToKg(pound Pound) Kg {
var res = Kg(pound / 2.205)
return res
}
//MileToKm converter
func (conv Converter) MileToKm(mile Mile) Km {
var res = Km(mile * 1.609344)
return res
}
//KmToMile converter
func (conv Converter) KmToMile(km Km) Mile {
var res = Mile(km / 1.609344)
return res
}
//KgToStone Converter
func (conv Converter) KgToStone(kg Kg) Stone {
var res = Stone(kg * 6.35029)
return res
}
//StoneToKg Converter
func (conv Converter) StoneToKg(stone Stone) Kg {
var res = Kg(stone / 6.35029)
return res
}
//CalToJoule Converter
func (conv Converter) CalToJoule(cal Cal) Joule {
var res = Joule(cal * 4.186)
return res
}
//JouleToCal Converter
func (conv Converter) JouleToCal(joule Joule) Cal {
var res = Cal(joule / 4.186)
return res
}
//Pounds to Newton Converter
func (conv Converter) PoundToNewton(pound Pound) Newton {
var res = Newton(pound * 4.448)
return res
}
//Newton To Pounds Converter
func (conv Converter) NewtonToPound(newton Newton) Pound {
var res = Pound(newton / 4.448)
return res
}
func main() {
conv := Converter{}
fmt.Println(conv.CentToFeet(10))
fmt.Println(conv.FeetToCent(10))
fmt.Println(conv.MinToSec(10))
fmt.Println(conv.SecToMin(10))
fmt.Println(conv.SecToMilSec(10))
fmt.Println(conv.MilSecToSec(10))
fmt.Println(conv.SecToMilSec(10))
fmt.Println(conv.MilSecToSec(10))
fmt.Println(conv.CelToFah(10))
fmt.Println(conv.FahToCel(10))
fmt.Println(conv.RadToDeg(10))
fmt.Println(conv.DegToRad(10))
fmt.Println(conv.KgToPound(10))
fmt.Println(conv.PoundToKg(10))
fmt.Println(conv.MileToKm(10))
fmt.Println(conv.KmToMile(10))
fmt.Println(conv.KgToStone(10))
fmt.Println(conv.StoneToKg(10))
fmt.Println(conv.CalToJoule(10))
fmt.Println(conv.JouleToCal(10))
fmt.Println(conv.PoundToNewton(10))
fmt.Println(conv.NewtonToPound(10))
}