Skip to content

Commit 893026b

Browse files
committed
create package
1 parent 36f040d commit 893026b

File tree

4 files changed

+68
-2
lines changed

4 files changed

+68
-2
lines changed

README-tr-TR.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
16. Interfaces ✓
2323
17. Goroutines ✓
2424
18. Channels ✓
25-
19. Create Yourself Package
25+
19. Create Yourself Package
2626
20. Test Package ✘
2727
21. Grafik çizdirmek ✘
2828
22. Arayüz Tasarımı GoLang ✘

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
16. Interfaces ✓
2525
17. Goroutines ✓
2626
18. Channels ✓
27-
19. Create Yourself Package
27+
19. Create Yourself Package
2828
20. Test Package ✘
2929
21. Draw Graph on GoLang ✘
3030
22. Gui on GoLang ✘

createOwnPackages/main.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"plateLib"
6+
)
7+
8+
9+
func main() {
10+
plate := plateLib.Plate{}
11+
plate.InitPlate("Çiçek")
12+
13+
fmt.Printf("%s\n",plate.GetName())
14+
15+
fmt.Printf("Water: %.2f\n",plate.GetWater())
16+
plate.Water()
17+
fmt.Printf("Water: %.2f\n",plate.GetWater())
18+
19+
fmt.Printf("Mineral :%.2f\n",plate.GetMineral())
20+
plate.Mineral()
21+
fmt.Printf("Mineral :%.2f\n",plate.GetMineral())
22+
}

createOwnPackages/plateLib.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//You need to add this file in $GOPATH
2+
package plateLib
3+
4+
type Plate struct {
5+
Pid string
6+
wRatio float64 //water Ratio
7+
mRatio float64 //mineral Ratio
8+
oxygen float64
9+
}
10+
11+
func (p *Plate) InitPlate(PId string) {
12+
p.Pid=PId
13+
p.wRatio=0.76
14+
p.mRatio=0.65
15+
p.oxygen=0.44532
16+
}
17+
18+
func (p *Plate) Water() float64{
19+
for p.wRatio<0.8{
20+
//Open the water line (cycle)
21+
p.wRatio+=0.01;
22+
}
23+
return p.wRatio
24+
}
25+
26+
func (p *Plate) Mineral()float64{
27+
for p.mRatio<0.8{
28+
//Open the mineral line (cycle)
29+
p.mRatio+=0.01;
30+
}
31+
return p.mRatio
32+
}
33+
func (p *Plate) oxySensor() {
34+
p.oxygen = 0.76 //Analog to Digital
35+
}
36+
func (p *Plate) GetName() string {
37+
return p.Pid
38+
}
39+
func (p *Plate) GetMineral() float64 {
40+
return p.mRatio
41+
}
42+
func (p *Plate) GetWater() float64 {
43+
return p.wRatio
44+
}

0 commit comments

Comments
 (0)