سلام من یک مینی پروژه برای مدیریت پیدا شدهها و گم شدهها نوشتم و میخواستم اینجا بارگزاری کنم تا نظرتون رو بدونم؟
package main
import "fmt"
type Lost struct {
Title string
Category string
Value int // high | mid | low
}
const (
HighValue = 5000000
MidValue = 2500000
LowValue = 1000000
)
type AuthCard struct {
Lost
AuthNumber int
}
var losts []Lost
var auths []AuthCard
func main() {
var input string
for input != "Exiting" {
fmt.Println("What do you want to do? \n (1.Add Found `Not Auth card`)\n (2.Add Found `an Auth card`) \n (3.View List of Found) \n (4.I have check my Auth info) \n (Type 'Exiting' to quit)")
fmt.Scanln(&input)
switch input {
case "1":
addNew()
case "2":
addNew2()
case "3":
ViewList()
case "4":
IhaveFound()
case "Exiting":
fmt.Println("Exiting....")
default:
fmt.Println(".................invalid command...............")
}
}
}
func addNew() []Lost {
var title string
fmt.Println("What is the title of your Found : ")
fmt.Scanln(&title)
var category string
fmt.Println("What is the category of your Found : ")
fmt.Scanln(&category)
var value int
fmt.Println("What is the value of your Found : `5000000 || 2500000 || 1000000` ")
fmt.Scanln(&value)
newLost := Lost{Title: title, Category: category, Value: value}
losts = append(losts, newLost)
fmt.Println("Added successfully!")
return losts
}
func addNew2() []AuthCard {
var title string
fmt.Println("What is the title of your Found : ")
fmt.Scanln(&title)
var category string
fmt.Println("What is the category of your Found : ")
fmt.Scanln(&category)
var value int
fmt.Println("What is the value of your Found : `5000000 || 2500000 || 1000000` ")
fmt.Scanln(&value)
var authNumber int
fmt.Println("Please write down AuthNumber: ")
fmt.Scanln(&authNumber)
newAuth := AuthCard{
Lost: Lost{
Title: title,
Category: category,
Value: value,
},
AuthNumber: authNumber,
}
auths = append(auths, newAuth)
fmt.Println("Added successfully!")
return auths
}
func ViewList() {
fmt.Println("\n--- Lost items ---")
for _, lost := range losts {
fmt.Println(lost)
}
fmt.Println("\n--- AuthCard items ---")
for _, a := range auths {
fmt.Println(a)
}
}
func IhaveFound() {
var input int
fmt.Println("Please enter auth number: ")
fmt.Scanln(&input)
found := false
for _, aLost := range auths {
if aLost.AuthNumber == input {
fmt.Println("✅ Found:", aLost)
found = true
break
}
}
if !found {
fmt.Println("❌ Not Found")
}
}