private static Sailboat CreateSailboat() { string identification = RandomID("S-"); int weight = random.Next(800, 6000); int maxSpeed = random.Next(0, 12); int length = random.Next(10, 60); Sailboat boat = new Sailboat(identification, weight, maxSpeed, length); return(boat); }
private static bool ReadFromFile() { string filePath = "Hamnen.txt"; if (File.Exists(filePath)) { List <Boat> boat = new List <Boat>(); List <string> lines = File.ReadAllLines(filePath).ToList(); foreach (string line in lines) { string[] entries = line.Split(','); if (entries[2] == "Rowboat") { Boat b = new Rowboat(entries[3], int.Parse(entries[4]), int.Parse(entries[5]), int.Parse(entries[6]), int.Parse(entries[7])); harbor[int.Parse(entries[0]), int.Parse(entries[1])] = b; } else if (entries[2] == "Motorboat") { Boat b = new Motorboat(entries[3], int.Parse(entries[4]), int.Parse(entries[5]), int.Parse(entries[6]), int.Parse(entries[7])); harbor[int.Parse(entries[0]), int.Parse(entries[1])] = b; } else if (entries[2] == "Sailboat") { Boat b = new Sailboat(entries[3], int.Parse(entries[4]), int.Parse(entries[5]), int.Parse(entries[6]), int.Parse(entries[7])); harbor[int.Parse(entries[0]), int.Parse(entries[1])] = b; } else if (entries[2] == "Cargoship") { Boat b = new Cargoship(entries[3], int.Parse(entries[4]), int.Parse(entries[5]), int.Parse(entries[6]), int.Parse(entries[7])); harbor[int.Parse(entries[0]), int.Parse(entries[1])] = b; } } return(true); } return(false); }