Exemple #1
0
        // override object.Equals
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            Road other = obj as Road;

            if (other == null)
            {
                return(false);
            }

            if (!Name.Equals(other.Name))
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        public static Road NewRoad(string roadName)
        {
            Road road;

            if (roadName.StartsWith("M"))
            {
                road = new Motorway(roadName);
            }
            else if (roadName.StartsWith("A"))
            {
                road = new ARoad(roadName);
            }
            else
            {
                road = new Road(roadName);
            }

            Roads.Add(road);
            Save();

            return(road);
        }