This commit is contained in:
2024-10-23 12:10:32 +00:00
parent c7e45139ec
commit a8148f2400
8 changed files with 230 additions and 5 deletions

View File

@@ -2,31 +2,72 @@ package main
import (
"bufio"
"fmt"
"example.com/note/note"
"example.com/note/todo"
"fmt"
"os"
"strings"
)
type saver interface {
Save() error
}
// type displayer interface {
// Display()
// }
type outputtable interface {
saver
Display()
}
// type outputtable interface {
// Save() error
// Display()
// }
func main() {
title, content := getNoteData()
todoText := getUserInput("Todo text: ")
userNote, err := note.New(title, content)
todo, err := todo.New(todoText)
if err != nil {
fmt.Println(err)
return
}
userNote.Display()
err = userNote.Save()
userNote, err := note.New(title, content)
if err != nil {
fmt.Println("Saving the note failed")
return
}
err = outputData(todo)
if err != nil {
return
}
outputData(userNote)
}
func outputData(data outputtable) error {
data.Display()
return saveData(data)
}
func saveData(data saver) error {
err := data.Save()
if err != nil {
fmt.Println("Saving the note failed")
return err
}
fmt.Println("Saving the note succeeded!")
return nil
}
func getNoteData() (string, string) {