Drawn the skeleton code for the structure of the project

This commit is contained in:
Karma Riuk 2023-08-03 21:07:58 +02:00
parent ae8ea353ca
commit 898d8463c8
9 changed files with 95 additions and 0 deletions

9
io/reader/image.go Normal file
View File

@ -0,0 +1,9 @@
package reader
import "maze-solver/maze"
type ImageReader struct{}
func (r *ImageReader) Read(filename string) (*maze.Maze, error) {
return nil, nil
}

7
io/reader/reader.go Normal file
View File

@ -0,0 +1,7 @@
package reader
import "maze-solver/maze"
type Reader interface {
Read(filename string) (*maze.Maze, error)
}

11
io/writer/image.go Normal file
View File

@ -0,0 +1,11 @@
package writer
import (
"maze-solver/maze"
)
type ImageWriter struct{}
func (w *ImageWriter) Write(filename string, maze *maze.SolvedMaze) error {
return nil
}

7
io/writer/writer.go Normal file
View File

@ -0,0 +1,7 @@
package writer
import "maze-solver/maze"
type Writer interface {
Write(filename string, maze *maze.SolvedMaze) error
}

25
maze-solver.go Normal file
View File

@ -0,0 +1,25 @@
package main
import (
"maze-solver/io/reader"
"maze-solver/io/writer"
"maze-solver/solver"
"maze-solver/utils"
)
func main() {
input := "filename"
output := "filename"
reader := &reader.ImageReader{}
writer := &writer.ImageWriter{}
solver := &solver.Bfs{}
maze, err := reader.Read(input)
utils.Check(err, "Couldn't read maze from %q", input)
solved := solver.Solve(maze)
err = writer.Write(output, solved)
utils.Check(err, "Couldn't write solved maze to %q", output)
}

10
maze/maze.go Normal file
View File

@ -0,0 +1,10 @@
package maze
type Maze interface {
maze()
}
type SolvedMaze interface {
Maze
solvedMaze()
}

9
solver/bfs.go Normal file
View File

@ -0,0 +1,9 @@
package solver
import "maze-solver/maze"
type Bfs struct{}
func (*Bfs) Solve(maze *maze.Maze) *maze.SolvedMaze {
return nil
}

7
solver/solver.go Normal file
View File

@ -0,0 +1,7 @@
package solver
import "maze-solver/maze"
type Solver interface {
Solve(*maze.Maze) *maze.SolvedMaze
}

10
utils/utils.go Normal file
View File

@ -0,0 +1,10 @@
package utils
import "log"
func Check(err error, msg string, args ...any) {
if err != nil {
log.Printf(msg, args...)
panic(err)
}
}