Prześlij pliki do 'Projekt1'

This commit is contained in:
Łukasz Korbanek 2018-12-20 18:15:24 +00:00
parent 69d7aca093
commit 8bd6891d74
2 changed files with 112 additions and 0 deletions

7
Projekt1/meds.txt Normal file
View File

@ -0,0 +1,7 @@
Lysopec:50
Palinidine:50
Sucrabine:50
Ademdocet:0
Tamsusetron:50
Benzodarone:50
Mechlosoline:0

105
Projekt1/zadanie.go Normal file
View File

@ -0,0 +1,105 @@
package main
import (
"fmt"
"time"
"color"
"io/ioutil"
"bufio"
"os"
"strings"
)
func main() {
p := fmt.Println
now := time.Now()
blue := color.New(color.FgBlue)
wheBackground := blue.Add(color.BgWhite)
wheBackground.Println(" TODAY IS: ")
p(" ",now.Weekday(),"|",now.Day(),now.Month(),now.Year())
white := color.New(color.FgWhite)
MagentaBackground := white.Add(color.BgMagenta)
MagentaBackground.Println("\nMED 6:00 14:00 22:00")
if int(now.Weekday()) == int(1) {
data, err := ioutil.ReadFile("1.txt")
if err != nil {
p("Error", err)
return
}
p(string(data))
} else {
if int(now.Weekday()) == int(2) {
data, err := ioutil.ReadFile("2.txt")
if err != nil {
p("Error", err)
return
}
p(string(data))
} else {
if int(now.Weekday()) == int(3) {
data, err := ioutil.ReadFile("3.txt")
if err != nil {
p("Error", err)
return
}
p(string(data))
} else {
if int(now.Weekday()) == int(4) {
data, err := ioutil.ReadFile("4.txt")
if err != nil {
p("Error", err)
return
}
p(string(data))
} else {
if int(now.Weekday()) == int(5) {
data, err := ioutil.ReadFile("5.txt")
if err != nil {
p("Error", err)
return
}
p(string(data))
} else {
if int(now.Weekday()) == int(6) {
data, err := ioutil.ReadFile("6.txt")
if err != nil {
p("Error", err)
return
}
p(string(data))
} else {
if int(now.Weekday()) == int(0) {
data, err := ioutil.ReadFile("7.txt")
if err != nil {
p("Error", err)
return
}
p(string(data))
} else {
p("Error")
}
}
}
}
}
}
}
red := color.New(color.FgRed)
whiteBackground := red.Add(color.BgWhite)
whiteBackground.Println("\n NEXT WEEK YOU'LL RUN OUT OF: ")
fileHandle, _ := os.Open("meds.txt")
defer fileHandle.Close()
fileScanner := bufio.NewScanner(fileHandle)
for fileScanner.Scan() {
if strings.HasSuffix(fileScanner.Text(), ":0") == true {
p(" ",fileScanner.Text())}
}
}