master > master: code go - entwicklung für interaktiven Modus gestartet
This commit is contained in:
108
code/golang/internal/endpoints/endpoints_it.go
Normal file
108
code/golang/internal/endpoints/endpoints_it.go
Normal file
@@ -0,0 +1,108 @@
|
||||
package endpoints
|
||||
|
||||
/* ---------------------------------------------------------------- *
|
||||
* IMPORTS
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
import (
|
||||
"ads/internal/core/logging"
|
||||
"ads/internal/menus"
|
||||
"ads/internal/setup"
|
||||
"reflect"
|
||||
|
||||
// algorithm_search_binary "ads/internal/algorithms/search/binary"
|
||||
// algorithm_search_interpol "ads/internal/algorithms/search/interpol"
|
||||
// algorithm_search_ith_element "ads/internal/algorithms/search/ith_element"
|
||||
// algorithm_search_jump "ads/internal/algorithms/search/jump"
|
||||
// algorithm_search_poison "ads/internal/algorithms/search/poison"
|
||||
algorithm_search_sequential "ads/internal/algorithms/search/sequential"
|
||||
// algorithm_sum_maxsubsum "ads/internal/algorithms/sum/maxsubsum"
|
||||
)
|
||||
|
||||
/* ---------------------------------------------------------------- *
|
||||
* ENDPOINT run interactive modus
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
// Startet App im interaktiven Modus
|
||||
func RunInteractive() error {
|
||||
logging.LogPlain(setup.Logo())
|
||||
_, err := menuMain.ShowMenu()
|
||||
logging.LogInfo("Programm terminiert.")
|
||||
return err
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- *
|
||||
* MENUS
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
var menuMain = menus.Menu{
|
||||
IsRoot: true,
|
||||
Path: []string{"Hauptmenü"},
|
||||
PromptMessages: []string{
|
||||
"Option wählen",
|
||||
},
|
||||
Options: []menus.MenuOption{
|
||||
{Label: "Version des Programms anzeigen", Action: actionShowVersion},
|
||||
{Label: "Suchalgorithmen", Submenu: &menuSearchAlgorithms},
|
||||
{Label: "Summenalgorithmen", Submenu: &menuSumAlgorithms},
|
||||
},
|
||||
DefaultOption: -1,
|
||||
}
|
||||
|
||||
var menuSearchAlgorithms = menus.Menu{
|
||||
IsRoot: false,
|
||||
Path: []string{"Hauptmenü", "Suchalgorithmus"},
|
||||
PromptMessages: []string{
|
||||
"Algorithmus wählen",
|
||||
},
|
||||
Options: []menus.MenuOption{
|
||||
{Label: "Binärsuchalgorithmus"},
|
||||
{Label: "Interpolationsalgorithmus"},
|
||||
{Label: "Suche i. kleinstes Element"},
|
||||
{Label: "Suche i. kleinstes Element", SubLabel: "D & C"},
|
||||
{Label: "Sprungsuche", SubLabel: "linear"},
|
||||
{Label: "Sprungsuche", SubLabel: "exponentiell"},
|
||||
{Label: "Giftsuche"},
|
||||
{Label: "Giftsuche", SubLabel: "optimiert"},
|
||||
{Label: "Sequentiellsuchalgorithmus", Action: actionAlgorithmSearchSequential},
|
||||
},
|
||||
DefaultOption: -1,
|
||||
}
|
||||
|
||||
var menuSumAlgorithms = menus.Menu{
|
||||
IsRoot: false,
|
||||
Path: []string{"Hauptmenü", "Suchalgorithmus"},
|
||||
PromptMessages: []string{
|
||||
"Algorithmus wählen",
|
||||
},
|
||||
Options: []menus.MenuOption{
|
||||
{Label: "Maximale Teilsumme", SubLabel: "brute force"},
|
||||
{Label: "Maximale Teilsumme", SubLabel: "D & C"},
|
||||
},
|
||||
DefaultOption: -1,
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- *
|
||||
* ACTIONS - basic
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
func actionShowVersion() error {
|
||||
logging.LogInfo("Version des Programms")
|
||||
Version()
|
||||
return nil
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- *
|
||||
* ACTIONS - Algorithmen
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
// TODO
|
||||
func actionAlgorithmSearchSequential() error {
|
||||
input_L := []int{45, 67}
|
||||
input_x := 6
|
||||
menus.PromptValue("L", "Liste von Integers", "z.B. \033[1m5 73 42\033[0m", reflect.TypeOf([]int{}))
|
||||
setup.DisplayStartOfCaseBlank()
|
||||
algorithm_search_sequential.FancySequentialSearch(input_L, input_x)
|
||||
setup.DisplayEndOfCase()
|
||||
return nil
|
||||
}
|
||||
@@ -20,11 +20,11 @@ import (
|
||||
)
|
||||
|
||||
/* ---------------------------------------------------------------- *
|
||||
* ENDPOINT run
|
||||
* ENDPOINT run non-interactive modus
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
// Liest Config Datei ein und führt Algorithmen auf Fälle durch
|
||||
func Run(path string) error {
|
||||
func RunNoninteractive(path string) error {
|
||||
var err error
|
||||
var err_case error
|
||||
|
||||
@@ -38,7 +38,7 @@ func Run(path string) error {
|
||||
}
|
||||
|
||||
// Fälle extrahieren
|
||||
cases := []types.CaseConfig{}
|
||||
cases := []types.UserConfigCase{}
|
||||
if config.Parts != nil && config.Parts.Cases != nil {
|
||||
cases = *config.Parts.Cases
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func Run(path string) error {
|
||||
err_case = nil
|
||||
problem := cases[i]
|
||||
setup.DisplayStartOfCase(i, problem.Description)
|
||||
inputs := types.InputsConfig{}
|
||||
inputs := types.UserConfigInputs{}
|
||||
if problem.Inputs != nil {
|
||||
inputs = *problem.Inputs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user