diff --git a/Projekt1/meds.txt b/Projekt1/meds.txt new file mode 100644 index 0000000..729cfb5 --- /dev/null +++ b/Projekt1/meds.txt @@ -0,0 +1,7 @@ +Lysopec:50 +Palinidine:50 +Sucrabine:50 +Ademdocet:0 +Tamsusetron:50 +Benzodarone:50 +Mechlosoline:0 \ No newline at end of file diff --git a/Projekt1/zadanie.go b/Projekt1/zadanie.go new file mode 100644 index 0000000..95dcfd9 --- /dev/null +++ b/Projekt1/zadanie.go @@ -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())} + } + +}