Drawn the skeleton code for the structure of the project
This commit is contained in:
parent
6d81f34a7c
commit
fbe066db17
9
io/reader/image.go
Normal file
9
io/reader/image.go
Normal 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
7
io/reader/reader.go
Normal 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
11
io/writer/image.go
Normal 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
7
io/writer/writer.go
Normal 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
25
maze-solver.go
Normal 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
10
maze/maze.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package maze
|
||||||
|
|
||||||
|
type Maze interface {
|
||||||
|
maze()
|
||||||
|
}
|
||||||
|
|
||||||
|
type SolvedMaze interface {
|
||||||
|
Maze
|
||||||
|
solvedMaze()
|
||||||
|
}
|
9
solver/bfs.go
Normal file
9
solver/bfs.go
Normal 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
7
solver/solver.go
Normal 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
10
utils/utils.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user