package main
import (
// "os"
"fmt"
"strconv"
)
type Function struct{
name string
arg1name string
arg2name string
result1name string
code string
}
func main(){
var input string = ""
var opt int = 0
fmt.Println(opt)
var functions [4]Function
var nf int = 0
//fmt.Println("functions:")
//fmt.Println(functions)
for {
fmt.Println("Menu")
fmt.Println("1.Create Function")
fmt.Println("2.List Functions")
//fmt.Println("3.Edit function")
//fmt.Println("4.Delete Function")
fmt.Println("0. To exit")
fmt.Println("Enter your option:")
fmt.Scanln(&input)
fmt.Println("Your selected option:" + input)
opt, err := strconv.Atoi(input)
if err == nil {
if opt == 0{
break
}
switch opt {
case 1:
fmt.Println("You selected Option 1.Create Function")
fmt.Println("Enter function name:")
var fname, arg1name, arg2name, result1name, code string
fmt.Scanln(&fname)
fmt.Println("Assuming function have two arguments, each type is int, return one value, its type is int")
fmt.Println("Enter first argument name:")
fmt.Scanln(&arg1name)
fmt.Println("Enter second argument name:")
fmt.Scanln(&arg2name)
fmt.Println("Enter return argument name:")
fmt.Scanln(&result1name)
fmt.Println("Enter Code:")
fmt.Scanln(&code)
f1 := Function{fname, arg1name, arg2name, result1name, code}
fmt.Println(f1)
functions[nf] = f1
nf ++
case 2:
fmt.Println("You selected Option 2.List Functions")
for i:=0;i f := functions[i]
fmt.Println(f)
}
case 0:
fmt.Println("You selected Option 0. To Exit")
default:
fmt.Println("Invalid option, try again")
//not working os.Exit(0)
}
}else{
fmt.Println("Enter number as option")
}
}
}
import (
// "os"
"fmt"
"strconv"
)
type Function struct{
name string
arg1name string
arg2name string
result1name string
code string
}
func main(){
var input string = ""
var opt int = 0
fmt.Println(opt)
var functions [4]Function
var nf int = 0
//fmt.Println("functions:")
//fmt.Println(functions)
for {
fmt.Println("Menu")
fmt.Println("1.Create Function")
fmt.Println("2.List Functions")
//fmt.Println("3.Edit function")
//fmt.Println("4.Delete Function")
fmt.Println("0. To exit")
fmt.Println("Enter your option:")
fmt.Scanln(&input)
fmt.Println("Your selected option:" + input)
opt, err := strconv.Atoi(input)
if err == nil {
if opt == 0{
break
}
switch opt {
case 1:
fmt.Println("You selected Option 1.Create Function")
fmt.Println("Enter function name:")
var fname, arg1name, arg2name, result1name, code string
fmt.Scanln(&fname)
fmt.Println("Assuming function have two arguments, each type is int, return one value, its type is int")
fmt.Println("Enter first argument name:")
fmt.Scanln(&arg1name)
fmt.Println("Enter second argument name:")
fmt.Scanln(&arg2name)
fmt.Println("Enter return argument name:")
fmt.Scanln(&result1name)
fmt.Println("Enter Code:")
fmt.Scanln(&code)
f1 := Function{fname, arg1name, arg2name, result1name, code}
fmt.Println(f1)
functions[nf] = f1
nf ++
case 2:
fmt.Println("You selected Option 2.List Functions")
for i:=0;i
fmt.Println(f)
}
case 0:
fmt.Println("You selected Option 0. To Exit")
default:
fmt.Println("Invalid option, try again")
//not working os.Exit(0)
}
}else{
fmt.Println("Enter number as option")
}
}
}
No comments:
Post a Comment