Skip to content

Commit e47c72c

Browse files
committed
go fmt
1 parent 4088873 commit e47c72c

File tree

3 files changed

+126
-136
lines changed

3 files changed

+126
-136
lines changed

advanced/banker.go

Lines changed: 77 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
var clear map[string]func() //create a map for storing clear funcs
1111
var username [5]string
1212
var balance [5]float32
13-
var house [5] int
14-
var hotels [5] int
15-
var value [5] float32
13+
var house [5]int
14+
var hotels [5]int
15+
var value [5]float32
1616
var choice int
1717

1818
func init() {
@@ -76,7 +76,7 @@ func PrintBalance() {
7676
fmt.Print(value[count])
7777
fmt.Println(" ")
7878
}
79-
fmt.Println("______________________________________________________________________________________________")
79+
fmt.Println("______________________________________________________________________________________________")
8080
}
8181

8282
func PrintMenu() {
@@ -117,7 +117,7 @@ func PerformAction() {
117117
General(1)
118118
case 7:
119119
General(2)
120-
case 8:
120+
case 8:
121121
Repairs()
122122
default:
123123
fmt.Println("try again")
@@ -127,7 +127,7 @@ func PerformAction() {
127127

128128
func BankTrans() {
129129
var amount float32
130-
var act int
130+
var act int
131131
fmt.Println(" Increase or decrease")
132132
fmt.Println(" _________________________________")
133133
fmt.Println(" ")
@@ -138,12 +138,11 @@ func BankTrans() {
138138
fmt.Scanln(&amount)
139139
Modify(act, amount)
140140
}
141-
142141

143-
func Houses(){
144-
var action int
142+
func Houses() {
143+
var action int
145144
var amount float32
146-
var act int
145+
var act int
147146
fmt.Println(" What do you wanna do?")
148147
fmt.Println(" _________________________________")
149148
fmt.Println(" ")
@@ -152,77 +151,76 @@ func Houses(){
152151
fmt.Println(" 3. Buy a Hotel 4.Sell a Hotel ")
153152
fmt.Println(" ")
154153
fmt.Println(" 5. Transfer a House ")
155-
fmt.Scanln(&act)
156-
switch act{
154+
fmt.Scanln(&act)
155+
switch act {
157156
case 1:
158-
fmt.Println(" What is the price?")
159-
fmt.Scanln(&amount)
160-
fmt.Println(" On which person")
161-
fmt.Println(" _________________________________")
162-
fmt.Println(" ")
163-
for {
164-
fmt.Scanln(&action)
165-
if action > 0 && action < 5 {
166-
break
157+
fmt.Println(" What is the price?")
158+
fmt.Scanln(&amount)
159+
fmt.Println(" On which person")
160+
fmt.Println(" _________________________________")
161+
fmt.Println(" ")
162+
for {
163+
fmt.Scanln(&action)
164+
if action > 0 && action < 5 {
165+
break
166+
}
167167
}
168-
}
169168
balance[action] = balance[action] - amount
170169
value[action] = value[action] + amount
171-
house[action]++
170+
house[action]++
172171
case 2:
173172
fmt.Println(" What is the price?")
174-
fmt.Scanln(&amount)
175-
fmt.Println(" On which person")
176-
fmt.Println(" _________________________________")
177-
fmt.Println(" ")
178-
for {
179-
fmt.Scanln(&action)
180-
if action > 0 && action < 5 {
181-
break
173+
fmt.Scanln(&amount)
174+
fmt.Println(" On which person")
175+
fmt.Println(" _________________________________")
176+
fmt.Println(" ")
177+
for {
178+
fmt.Scanln(&action)
179+
if action > 0 && action < 5 {
180+
break
181+
}
182182
}
183-
}
184183
balance[action] = balance[action] + amount
185-
value[action] = value[action] - amount
184+
value[action] = value[action] - amount
186185
house[action]--
187-
case 3:
186+
case 3:
188187
fmt.Println(" What is the price?")
189-
fmt.Scanln(&amount)
190-
fmt.Println(" On which person")
191-
fmt.Println(" _________________________________")
192-
fmt.Println(" ")
193-
for {
194-
fmt.Scanln(&action)
195-
if action > 0 && action < 5 {
196-
break
188+
fmt.Scanln(&amount)
189+
fmt.Println(" On which person")
190+
fmt.Println(" _________________________________")
191+
fmt.Println(" ")
192+
for {
193+
fmt.Scanln(&action)
194+
if action > 0 && action < 5 {
195+
break
196+
}
197197
}
198-
}
199198
balance[action] = balance[action] - amount
200199
value[action] = value[action] + amount
201-
hotels[action]++
200+
hotels[action]++
202201
case 4:
203202
fmt.Println(" What is the price?")
204-
fmt.Scanln(&amount)
205-
fmt.Println(" On which person")
206-
fmt.Println(" _________________________________")
207-
fmt.Println(" ")
208-
for {
209-
fmt.Scanln(&action)
210-
if action > 0 && action < 5 {
211-
break
203+
fmt.Scanln(&amount)
204+
fmt.Println(" On which person")
205+
fmt.Println(" _________________________________")
206+
fmt.Println(" ")
207+
for {
208+
fmt.Scanln(&action)
209+
if action > 0 && action < 5 {
210+
break
211+
}
212212
}
213-
}
214213
balance[action] = balance[action] + amount
215-
value[action] = value[action] - amount
216-
hotels[action]--
214+
value[action] = value[action] - amount
215+
hotels[action]--
217216
case 5:
218217
HouseTrans()
219218
default:
220219
fmt.Println(" try again")
221220
fmt.Scanln()
222221
}
223-
222+
224223
}
225-
226224

227225
func HouseTrans() {
228226
var action [2]int
@@ -253,14 +251,12 @@ func HouseTrans() {
253251
fmt.Scanln(&amount)
254252
balance[action[0]] = balance[action[0]] + amount
255253
balance[action[1]] = balance[action[1]] - amount
256-
value[action[0]] = value[action[0]] - amount
257-
value[action[1]] = value[action[1]] + amount
258-
house[action[1]]++
259-
house[action[0]]--
254+
value[action[0]] = value[action[0]] - amount
255+
value[action[1]] = value[action[1]] + amount
256+
house[action[1]]++
257+
house[action[0]]--
260258
}
261259

262-
263-
264260
func NormTrans() {
265261
var action [2]int
266262
var amount float32
@@ -292,9 +288,6 @@ func NormTrans() {
292288
balance[action[1]] = balance[action[1]] + amount
293289
}
294290

295-
296-
297-
298291
func Inc10() {
299292
var action int
300293
fmt.Println(" On which person")
@@ -383,37 +376,35 @@ func Modify(act int, amount float32) {
383376
}
384377
}
385378

386-
387-
func Repairs(){
388-
var action int
389-
var amount int
390-
var houses[5] int
391-
var hotels[5] int
379+
func Repairs() {
380+
var action int
381+
var amount int
382+
var houses [5]int
383+
var hotels [5]int
392384
fmt.Println(" Which type of repairs ?")
393-
fmt.Println(" ________________________________")
394-
fmt.Println(" ")
385+
fmt.Println(" ________________________________")
386+
fmt.Println(" ")
395387
fmt.Println(" 1. major 2.minor")
396-
fmt.Println(" ")
388+
fmt.Println(" ")
397389
fmt.Scanln(&action)
398-
fmt.Println(" Houses ?")
399-
fmt.Println(" ________________________________")
400-
fmt.Println(" ")
390+
fmt.Println(" Houses ?")
391+
fmt.Println(" ________________________________")
392+
fmt.Println(" ")
401393
fmt.Scanln(&houses[0])
402-
fmt.Println(" Hotels ?")
403-
fmt.Println(" ________________________________")
404-
fmt.Println(" ")
394+
fmt.Println(" Hotels ?")
395+
fmt.Println(" ________________________________")
396+
fmt.Println(" ")
405397
fmt.Scanln(&hotels[0])
406-
switch action {
398+
switch action {
407399
case 1:
408-
amount = (houses[0]*40) + (hotels[0]*115)
400+
amount = (houses[0] * 40) + (hotels[0] * 115)
409401
case 2:
410-
amount = (houses[0]*25) + (hotels[0]*100)
402+
amount = (houses[0] * 25) + (hotels[0] * 100)
411403
default:
412404
fmt.Println(" try again")
413405
fmt.Scanln()
414406
}
415-
Modify(2,float32(amount))
416-
407+
Modify(2, float32(amount))
417408

418409
}
419410

@@ -428,4 +419,3 @@ func main() {
428419
}
429420

430421
}
431-
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
// Go program to illustrate how a
2-
// function return multiple values
3-
package main
4-
5-
import "fmt"
6-
7-
// myfunc return 3 values of int type
8-
func myfunc(p, q int)(int, int, int ){
9-
return p - q, p * q, p + q
10-
}
11-
12-
// Main Method
13-
func main() {
14-
15-
// The return values are assigned into
16-
// three different variables
17-
var myvar1, myvar2, myvar3 = myfunc(4, 2)
18-
19-
// Display the values
20-
fmt.Printf("Result is: %d", myvar1 )
21-
fmt.Printf("\nResult is: %d", myvar2)
22-
fmt.Printf("\nResult is: %d", myvar3)
23-
}
1+
// Go program to illustrate how a
2+
// function return multiple values
3+
package main
4+
5+
import "fmt"
6+
7+
// myfunc return 3 values of int type
8+
func myfunc(p, q int) (int, int, int) {
9+
return p - q, p * q, p + q
10+
}
11+
12+
// Main Method
13+
func main() {
14+
15+
// The return values are assigned into
16+
// three different variables
17+
var myvar1, myvar2, myvar3 = myfunc(4, 2)
18+
19+
// Display the values
20+
fmt.Printf("Result is: %d", myvar1)
21+
fmt.Printf("\nResult is: %d", myvar2)
22+
fmt.Printf("\nResult is: %d", myvar3)
23+
}

beginner/draw_cuboid.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
package main
2-
2+
33
import "fmt"
4-
4+
55
func cuboidDraw(drawX, drawY, drawZ int) {
6-
fmt.Printf("Cuboid %d %d %d:\n", drawX, drawY, drawZ)
7-
cubeLine(drawY+1, drawX, 0, "+-")
8-
for i := 1; i <= drawY; i++ {
9-
cubeLine(drawY-i+1, drawX, i-1, "/ |")
10-
}
6+
fmt.Printf("Cuboid %d %d %d:\n", drawX, drawY, drawZ)
7+
cubeLine(drawY+1, drawX, 0, "+-")
8+
for i := 1; i <= drawY; i++ {
9+
cubeLine(drawY-i+1, drawX, i-1, "/ |")
10+
}
1111
cubeLine(0, drawX, drawY, "+-|")
12-
for i := 4*drawZ - drawY - 2; i > 0; i-- {
13-
cubeLine(0, drawX, drawY, "| |")
14-
}
15-
cubeLine(0, drawX, drawY, "| +")
16-
for i := 1; i <= drawY; i++ {
17-
cubeLine(0, drawX, drawY-i, "| /")
18-
}
19-
cubeLine(0, drawX, 0, "+-\n")
12+
for i := 4*drawZ - drawY - 2; i > 0; i-- {
13+
cubeLine(0, drawX, drawY, "| |")
14+
}
15+
cubeLine(0, drawX, drawY, "| +")
16+
for i := 1; i <= drawY; i++ {
17+
cubeLine(0, drawX, drawY-i, "| /")
18+
}
19+
cubeLine(0, drawX, 0, "+-\n")
2020
}
21-
21+
2222
func cubeLine(n, drawX, drawY int, cubeDraw string) {
23-
fmt.Printf("%*s", n+1, cubeDraw[:1])
24-
for d := 9*drawX - 1; d > 0; d-- {
25-
fmt.Print(cubeDraw[1:2])
26-
}
27-
fmt.Print(cubeDraw[:1])
28-
fmt.Printf("%*s\n", drawY+1, cubeDraw[2:])
23+
fmt.Printf("%*s", n+1, cubeDraw[:1])
24+
for d := 9*drawX - 1; d > 0; d-- {
25+
fmt.Print(cubeDraw[1:2])
26+
}
27+
fmt.Print(cubeDraw[:1])
28+
fmt.Printf("%*s\n", drawY+1, cubeDraw[2:])
2929
}
30-
30+
3131
func main() {
3232
fmt.Println("Enter 3 dimensions of Cuboid : ")
33-
var l,b,h int
34-
fmt.Scanln(&l)
33+
var l, b, h int
34+
fmt.Scanln(&l)
3535
fmt.Scanln(&b)
3636
fmt.Scanln(&h)
37-
cuboidDraw(l,b,h)
37+
cuboidDraw(l, b, h)
3838
}

0 commit comments

Comments
 (0)