Skip to content

Instantly share code, notes, and snippets.

@cored
Created September 29, 2018 18:03
Show Gist options
  • Save cored/4a767b0e87be8741cd813cdfa5ce82fa to your computer and use it in GitHub Desktop.
Save cored/4a767b0e87be8741cd813cdfa5ce82fa to your computer and use it in GitHub Desktop.
package main
import (
"os"
"fmt"
"gitlab.com/george.rafael/restaurant-gr/internal/restaurant"
"gitlab.com/george.rafael/restaurant-gr/internal/stats"
)
func main() {
// Tables are hardcoded for simplicity
tables := []restaurant.Table{
restaurant.Table{Size: 2},
restaurant.Table{Size: 2},
restaurant.Table{Size: 2},
restaurant.Table{Size: 2},
restaurant.Table{Size: 3},
restaurant.Table{Size: 3},
restaurant.Table{Size: 4},
restaurant.Table{Size: 4},
restaurant.Table{Size: 5},
restaurant.Table{Size: 6},
}
// The stats manager is used to record how long customers
// wait to be seated, how many customers give up waiting and leave
statsManager := stats.StartNewManager()
seatingManager := restaurant.StartNewSeatingManager(tables, statsManager)
err := restaurant.ReadEvents(os.Stdin, seatingManager)
if err != nil {
panic(err)
}
// Wait for the restaurant to close
seatingManager.WaitClosed()
// Print out the statistics for the customers
fmt.Printf("\n\nSTATS: %v\n", statsManager.GetStats())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment