Commit 5db49d87 authored by noasakurajin's avatar noasakurajin
Browse files

adding check functions for TrainProperties

parent 0e0a2022
......@@ -8,7 +8,7 @@ type VersionStruct struct {
Patch int64
}
func (b *VersionStruct) toString() string{
func (b *VersionStruct) ToString() string{
var retVal string
retVal += strconv.FormatInt(b.Major,10) + "."
......@@ -45,3 +45,24 @@ func (b *TrainProperties040) Cast() TrainProperties{
retVal.VelocityUnit = b.VelocityUnit
return retVal
}
func (b *TrainProperties) IsValid() bool{
tmp := b.TrainProperties040
return tmp.IsValid()
}
func (b *TrainProperties040) IsValid() bool{
if b.Name == "" || b.Mass == 0{
return false
}
if b.MaxVelocity == 0 || b.MaxAcceleration == 0{
return false
}
if ! (b.VelocityUnit == "ms" || b.VelocityUnit == "kmh" || b.VelocityUnit == ""){
return false
}
return true
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment