コード例 #1
0
ファイル: Galaxy.cs プロジェクト: zlatkovtv/SoftUni_OOP
        public void TravelTo(IStarship ship, StarSystem destination)
        {
            if (ship.Health <= 0)
            {
                throw new ShipException("Ship is destroyed!");
            }
            var startLocation = ship.Location;
            if (!startLocation.NeighbourStarSystems.ContainsKey(destination))
            {
                throw new LocationOutOfRangeException(string.Format(
                    "Cannot travel directly from {0} to {1}",
                    startLocation.Name, destination.Name));
            }

            if (ship.Location.Name.Equals(destination.Name))
            {
                throw new ShipException(string.Format(Messages.ShipAlreadyInStarSystem, destination.Name));
            }

            double requiredFuel = startLocation.NeighbourStarSystems[destination];
            if (ship.Fuel < requiredFuel)
            {
                throw new InsufficientFuelException(string.Format(
                    "Not enough fuel to travel to {0} - {1}/{2}",
                    destination.Name, ship.Fuel, requiredFuel));
            }

            ship.Fuel -= requiredFuel;
            ship.Location = destination;
        }
コード例 #2
0
ファイル: Dreadnought.cs プロジェクト: ROSSFilipov/CSharp
 public Dreadnought(string name, StarSystem location)
     : base(name, location)
 {
     this.Health = ShipValues.DreadnoughtHealth;
     this.Shields = ShipValues.DreadnoughtShields;
     this.Damage = ShipValues.DreadnoughtDamage;
     this.Fuel = ShipValues.DreadnoughtFuel;
 }
コード例 #3
0
 protected Starship(string name, int health, int shields, int damage, double fuel, StarSystem location)
 {
     this.Name = name;
     this.Health = health;
     this.Shields = shields;
     this.Damage = damage;
     this.Fuel = fuel;
 }
コード例 #4
0
ファイル: Cruiser.cs プロジェクト: ROSSFilipov/CSharp
 public Cruiser(string name, StarSystem location)
     : base(name, location)
 {
     this.Health = ShipValues.CruiserHealth;
     this.Shields = ShipValues.CruiserShields;
     this.Damage = ShipValues.CruiserDamage;
     this.Fuel = ShipValues.CruiserFuel;
 }
コード例 #5
0
ファイル: Ship.cs プロジェクト: peterkirilov/SoftUni-1
 protected Ship(string name, int health, int shield, int damage, int fuel, StarSystem location)
 {
     this.Name = name;
     this.Health = health;
     this.Shields = shield;
     this.Damage = damage;
     this.Fuel = fuel;
     this.Location = location;
 }
コード例 #6
0
ファイル: Frigate.cs プロジェクト: ROSSFilipov/CSharp
 public Frigate(string name, StarSystem location)
     : base(name, location)
 {
     this.Health = ShipValues.FrigateHealth;
     this.Shields = ShipValues.FrigateShields;
     this.Damage = ShipValues.FrigateDamage;
     this.Fuel = ShipValues.FrigateFuel;
     this.ProjectilesFired = 0;
 }
コード例 #7
0
ファイル: Starship.cs プロジェクト: monikaBchvarova/C-Sharp
 protected Starship(string name, StarSystem location, int health, int shileds, int damage, double fuel)
 {
     this.Name = name;
     this.Location = location;
     this.health = health;
     this.shields = shileds;
     this.damage = damage;
     this.fuel = fuel;
     this.enhancementsList = new List<Enhancement>();
 }
コード例 #8
0
 protected Starship(string name, int health, int shields, int damage, double fuel, StarSystem location)
 {
     this.Name = name;
     this.Health = health;
     this.Shields = shields;
     this.Damage = damage;
     this.Fuel = fuel;
     this.Location = location;
     this.enhancements = new List<Enhancement>();
 }
コード例 #9
0
ファイル: Ship.cs プロジェクト: zlatkovtv/SoftUni_OOP
 protected Ship(string name, int health, int shields, int damage, double fuel, StarSystem location)
 {
     shipNames = new List<string>();
     shipNames.Add(name);
     enhancementsList = new List<Enhancement>();
     Name = name;
     Health = health;
     Shields = shields;
     Damage = damage;
     Fuel = fuel;
     Location = location;
 }
コード例 #10
0
 public IStarship CreateShip(StarshipType type, string name, StarSystem location)
 {
     switch (type)
     {
         case StarshipType.Frigate:
             return new Frigate(name,location);
         case StarshipType.Cruiser:
             return new Cruiser(name, location);
         case StarshipType.Dreadnought:
             return new Dreadnought(name, location);
         default:
             throw new NotSupportedException("Starship type not supported.");
     }
 }
コード例 #11
0
ファイル: ShipFactory.cs プロジェクト: simooo93/Exams
 public IStarship CreateShip(StarshipType type, string name, StarSystem location)
 {
     switch (type)
     {
         case StarshipType.Frigate:
             // TODO:
         case StarshipType.Cruiser:
             // TODO:
         case StarshipType.Dreadnought:
             // TODO:
         default:
             throw new NotSupportedException("Starship type not supported.");
     }
 }
コード例 #12
0
ファイル: ShipFactory.cs プロジェクト: peterkirilov/SoftUni-1
        public IStarship CreateShip(StarshipType type, string name, StarSystem location)
        {
            IStarship ship;
            switch (type)
            {
                case StarshipType.Frigate:
                    ship = new Frigate(name, location);
                    break;
                case StarshipType.Cruiser:
                    ship = new Cruiser(name, location);
                    break;
                case StarshipType.Dreadnought:
                    ship = new Dreadnought(name, location);
                    break;
                default:
                    throw new NotSupportedException("Starship type not supported.");
            }

            Console.WriteLine(Messages.CreatedShip, ship.GetType().Name, ship.Name);
            return ship;
        }
コード例 #13
0
        public void TravelTo(IStarship ship, StarSystem destination)
        {
            var startLocation = ship.Location;
            if (!startLocation.NeighbourStarSystems.ContainsKey(destination))
            {
                throw new LocationOutOfRangeException(string.Format(
                    "Cannot travel directly from {0} to {1}",
                    startLocation.Name, destination.Name));
            }

            double requiredFuel = startLocation.NeighbourStarSystems[destination];
            if (ship.Fuel < requiredFuel)
            {
                throw new InsufficientFuelException(string.Format(
                    "Not enough fuel to travel to {0} - {1}/{2}",
                    destination.Name, ship.Fuel, requiredFuel));
            }

            ship.Fuel -= requiredFuel;
            ship.Location = destination;
        }
コード例 #14
0
        public static void SeedStarSystems(Galaxy galaxy)
        {
            var artemisTau = new StarSystem("Artemis-Tau");
            var serpentNebula = new StarSystem("Serpent-Nebula");
            var hadesGamma = new StarSystem("Hades-Gamma");
            var keplerVerge = new StarSystem("Kepler-Verge");

            galaxy.StarSystems.Add(artemisTau);
            galaxy.StarSystems.Add(serpentNebula);
            galaxy.StarSystems.Add(hadesGamma);
            galaxy.StarSystems.Add(keplerVerge);

            artemisTau.NeighbourStarSystems.Add(serpentNebula, 50);
            artemisTau.NeighbourStarSystems.Add(keplerVerge, 120);

            serpentNebula.NeighbourStarSystems.Add(artemisTau, 50);
            serpentNebula.NeighbourStarSystems.Add(hadesGamma, 360);

            hadesGamma.NeighbourStarSystems.Add(serpentNebula, 360);
            hadesGamma.NeighbourStarSystems.Add(keplerVerge, 145);

            keplerVerge.NeighbourStarSystems.Add(hadesGamma, 145);
            keplerVerge.NeighbourStarSystems.Add(artemisTau, 120);
        }
コード例 #15
0
ファイル: Dreadnought.cs プロジェクト: craghagBg/AllProjects
 public Dreadnought(string name, int health, int shield, int damage, double fuel, StarSystem location)
     : base(name, health, shield, damage, fuel, location)
 {
 }
コード例 #16
0
ファイル: Cruiser.cs プロジェクト: cap7ainjack/OOP-Csharp
 public Cruiser(string name, StarSystem location)
     : base(name, DefaultCruiserHealth, DefaultCruiserShield, DefaultCruiserDamage,
           DefaultCruisereFuel, location)
 {
 }
コード例 #17
0
ファイル: Dreadnought.cs プロジェクト: ikolev94/Exercises
 public Dreadnought(string name, StarSystem locatiin)
     : base(name, DreadnoughtHealth, DreadnoughtShields, DreadnoughtDamage, DreadnoughtFuel, locatiin)
 {
 }
コード例 #18
0
ファイル: Frigate.cs プロジェクト: monikaBchvarova/C-Sharp
 public Frigate(string name, StarSystem location)
     : base(name, location, health: 60, shileds: 50, damage: 30, fuel: 220)
 {
     this.ProjectilesFired = 0;
     this.Type = StarshipType.Frigate;
 }
コード例 #19
0
 public Dreadnought(string name, StarSystem location)
     : base(name, DefHealth, DefShields, DefDamage, DefFuel, location)
 {
     this.StarshipType = StarshipType.Cruiser;
 }
コード例 #20
0
 public Cruiser(string name, StarSystem location)
     : base(name, location, CruiserInitialHealth, CruiserInitiaShields, CruisereInitiaDamage, CruiserInitiaFuel)
 {
 }
コード例 #21
0
 public Dreadnought(string name, StarSystem location)
     : base(name, 200, 300, 150, 700, location)
 {
 }
コード例 #22
0
 public Cruiser(string name, StarSystem location)
     : base(name, 100, 100, 50, 300, location)
 {
 }
コード例 #23
0
 public Dreadnought(string name, int health, int shields, int damage, double fuel, StarSystem locationStarSystem)
     : base(name, 200, 300, 150, 700, locationStarSystem)
 {
 }
コード例 #24
0
 public Frigate(string name, StarSystem location)
     : base(name, DefaultHealth, DefaultShield, DefaultDamage, DefaultFuel, location)
 {
 }
コード例 #25
0
ファイル: Frigate.cs プロジェクト: craghagBg/AllProjects
 public Frigate(string name, StarSystem location)
     : this(name, 0, 0, 0, 0, location)
 {
     this.Name = name;
     this.Location = location;
 }
コード例 #26
0
ファイル: Dreadnought.cs プロジェクト: craghagBg/AllProjects
 public Dreadnought(string name, StarSystem location)
     : this(name, 0, 0, 0, 0, location)
 {
     this.Name = name;
     this.Location = location;
 }
コード例 #27
0
 public Cruiser(string name, StarSystem location)
     : base(name, CruiserHealth, CruiserShields, CruiserDamage, CruiserFuel, location)
 {
 }
コード例 #28
0
 public Frigate(string name, StarSystem location)
     : base(name, FrigateHealth, FrigateShields, FrigateDamage, FrigateFuel, location)
 {
 }
コード例 #29
0
ファイル: Cruiser.cs プロジェクト: AsenTahchiyski/SoftUni
 public Cruiser(string name, int health, int shields, int damage, double fuel, StarSystem location)
     : base(name, health, shields, damage, fuel, location)
 {
     this.Type = StarshipType.Cruiser;
 }
コード例 #30
0
ファイル: Cruiser.cs プロジェクト: eslavov11/SoftUni-Homework
 public Cruiser(string name, StarSystem location)
     : base(name, DefaultHealth, DefaultShields, DefaultDamage, DefaultFuel, location)
 {
 }