CS 3 Project (Inheritance, Access Modifiers, Interface)

Starcraft II ( sorry girls, next time na kayo :D )
Instructions

        Create the following classes in two separate packages (Buildings and Units)
        Use the proper inheritance and interfaces to make coding easier.
        Create Abstract Classes and Interfaces as needed
        Create additional function and variables as needed
        Try to apply the necessary access modifiers for the functions and attributes/variables
        Point distribution: 10 points per class + 30 pts worth of bonuses (180/150).

List of Buildings                                      List of Units
      Command Center                                        Infantry
      Barracks                                                      o SCV
      Factory                                                       o Marine
      Starport                                                      o Marauder
                                                                     o Ghost
                                                             Vehicles
                                                                     o Hellion
                                                                     o Siege Tank
                                                                     o Thor
                                                             Ships
                                                                     o Medivac
                                                                     o Viking
                                                                     o Banshee
                                                                     o Battlecruiser



Basic Attributes and Functions

        All buildings and units have an attribute hp and maxhp. Both ints. Hp is initially equal to maxhp.
        All buildings and units have a String attribute, status. That is “Normal” at first but changes
         depending on what happens to them.
        All building and units have two attributes (double) for their x and y coordinates.
        All buildings and units have a function takeDamage(int damage) that decreases their hp by
         damage.
        If a buildings hp is lower than 10% of its maxhp, its status is “Burning”.
        All units have a move function (x and y parameters) that set their x and y coordinates to new
         ones.
        Ships have the function fly which is the same as move.
        Only specific units can attack units that can fly.
Infantry Units

      All infantry units have an attribute range(double)
      All infantry units have a function attack(Target) which deals damage to Target as long as the
       distance between the unit and the Target is less than or equal to the range. Target is either a
       building or unit.
      If a unit’s hp is 0 or less, its status is “Dead” and cannot attack anymore.
      SCV
            o Range is 1
            o Damage is 5
            o Maxhp is 45
            o Has function buildCommandCenter which returns a CommandCenter object
            o Has function buildBarracks which returns a Barracks object
            o Has function build Factory which returns a Factory object
            o Has function buildStarport which returns a Starport object
            o Cannot attack flying units
      Marines
            o Range is 5
            o Attack deals 6 damage
            o Maxhp is 45
            o Can attack any other unit or building
      Marauder
            o Range is 6
            o Attack deals 10 damage
            o Maxhp is 125
            o Cannot attack units that fly
            o Target’s status is changed to “Slow”
      Ghost
            o Range is 6
            o Maxhp is 100
            o Ghosts have an attribute SP which is default to 200
            o Attack deals 10 damage
            o Has an function snipe(Target)
                      Target must be an Infantry Unit
                      Snipe deals 45 damage to Target
                      Range is 10
            o Has function cloak
                      If SP is greater than or equal to 25, sets status to “Invisible”
                      Decreases SP by 25
                      If a ghost is invisible, it does not take damage
Vehicle Units

      All vehicles have an attribute range(double)
      All vehicles have a function attack(Target) which deals damage to Target as long as the distance
       between the unit and the Target is less than or equal to the range. Target is either a building or
       unit.
      If a vehicle’s hp is 0 or less, its status is “Dead” and cannot attack anymore.
      Hellion
            o Range is 5
            o Attack deals 8 damage
            o Maxhp is 90
            o Hellions cannot attack flying units
      Siege Tank
            o Range is 7
            o Attack deals 15 damage
            o Maxhp is 160
            o Siege Tanks cannot attack flying units
            o Siege Tanks have a siegeMode function
                      Status is set to “Siege”
                      Range is now 13 and damage from attacks is now 35
                      However you cannot attack targets that are within 2 distance
            o Siege Tanks also have a function normalMode where status is back to “Normal”, range
                and damage are also returned to normal
      Thor
            o Range is 7
            o Attack damage is 30
            o Maxhp is 400
Ship Units

      All ships units are flying
      Not all ships can attack
      If a ship’s hp is 0 or less, its status is “Dead” and cannot attack anymore.
      Viking
            o Range is 9
            o Attack deals 12 damage
            o Maxhp is 120
            o Can only attack flying units
      Medivac
            o Cannot attack units
            o Maxhp is 150
            o Has an attribute, cargo which is an array of units (size 6)
            o Has a load(unit) function which adds the unit to the array
            o Has unload(int) function which returns the unit at the int index of the array
            o If the Medivac moves, the units in cargo moves with it
            o Meduvacs have an attribute SP initially at 200
            o Medivac can also heal(Target)
                      Increases Target’s hp by 3, not exceeding the maxhp as long as SP is greater
                          than 0.
                      Decreases hp by 1.
      Banshee
            o Range is 6
            o Attack deals 12 damage
            o Maxhp is 140
            o Has an attribute SP, similar to ghosts
            o Cannot attack other ships
            o Can cloak, similar to ghosts
      Battlecruiser
            o Range is 6
            o Attack deals 8 damage
            o Maxhp is 550
            o Has an attribute SP which is initially 250
            o Has a function weaponRefit(Target)
                      Deals 300 damage to the target as long as SP is greater than or equal to 125
                      Decreases SP by 125
                      Range is 10
Buildings

      CommandCenter
           o Maxhp is 1500
           o Has function trainSCV, which returns an SCV object
      Barracks
           o Maxhp is 1000
           o Has functions:
                  trainMarine, which returns a Marine object
                  trainMarauder, which returns a Marauder object
                  trainGhost, which returns a Ghost object
      Factory
           o Maxhp is 1250
           o Has functions:
                  trainHellion, which returns a Hellion object
                  trainSiegeTank, which returns a SiegeTank object
                  trainThor, which returns a Thor object
      Starport
           o Maxhp is 1300
           o Has functions:
                  trainViking, which returns a Viking object
                  trainMedivac, which returns a Medivac object
                  trainBanshee, which returns a Banshee object
                  trainBattlecruise, which returns a Battlecruiser object

BONUS FUNCTIONS

      Buildings have the ability liftoff (5 pts)
            o Status is set to “Flying”
            o While flying only units that can attack flying units can attack it
      Buildings also have ability to land (5 pts)
            o Status is set to “Normal”
            o While flying only units that can attack ground units can attack it
      Vikings also have the ability to lift-off and land (5 pts)
            o While flying, Vikings can only attack flying units
            o While landed, Vikings can only attack units that are not flying
      Hellions deal 16 damage to Infantry units (5 pts)
      If a Medivac dies, all unit inside it also dies (5 pts)
      Output a message (System.out.println) whenever an attack is successful or not. (5 pts)

Cs project instructions

  • 1.
    CS 3 Project(Inheritance, Access Modifiers, Interface) Starcraft II ( sorry girls, next time na kayo :D ) Instructions  Create the following classes in two separate packages (Buildings and Units)  Use the proper inheritance and interfaces to make coding easier.  Create Abstract Classes and Interfaces as needed  Create additional function and variables as needed  Try to apply the necessary access modifiers for the functions and attributes/variables  Point distribution: 10 points per class + 30 pts worth of bonuses (180/150). List of Buildings List of Units  Command Center  Infantry  Barracks o SCV  Factory o Marine  Starport o Marauder o Ghost  Vehicles o Hellion o Siege Tank o Thor  Ships o Medivac o Viking o Banshee o Battlecruiser Basic Attributes and Functions  All buildings and units have an attribute hp and maxhp. Both ints. Hp is initially equal to maxhp.  All buildings and units have a String attribute, status. That is “Normal” at first but changes depending on what happens to them.  All building and units have two attributes (double) for their x and y coordinates.  All buildings and units have a function takeDamage(int damage) that decreases their hp by damage.  If a buildings hp is lower than 10% of its maxhp, its status is “Burning”.  All units have a move function (x and y parameters) that set their x and y coordinates to new ones.  Ships have the function fly which is the same as move.  Only specific units can attack units that can fly.
  • 2.
    Infantry Units  All infantry units have an attribute range(double)  All infantry units have a function attack(Target) which deals damage to Target as long as the distance between the unit and the Target is less than or equal to the range. Target is either a building or unit.  If a unit’s hp is 0 or less, its status is “Dead” and cannot attack anymore.  SCV o Range is 1 o Damage is 5 o Maxhp is 45 o Has function buildCommandCenter which returns a CommandCenter object o Has function buildBarracks which returns a Barracks object o Has function build Factory which returns a Factory object o Has function buildStarport which returns a Starport object o Cannot attack flying units  Marines o Range is 5 o Attack deals 6 damage o Maxhp is 45 o Can attack any other unit or building  Marauder o Range is 6 o Attack deals 10 damage o Maxhp is 125 o Cannot attack units that fly o Target’s status is changed to “Slow”  Ghost o Range is 6 o Maxhp is 100 o Ghosts have an attribute SP which is default to 200 o Attack deals 10 damage o Has an function snipe(Target)  Target must be an Infantry Unit  Snipe deals 45 damage to Target  Range is 10 o Has function cloak  If SP is greater than or equal to 25, sets status to “Invisible”  Decreases SP by 25  If a ghost is invisible, it does not take damage
  • 3.
    Vehicle Units  All vehicles have an attribute range(double)  All vehicles have a function attack(Target) which deals damage to Target as long as the distance between the unit and the Target is less than or equal to the range. Target is either a building or unit.  If a vehicle’s hp is 0 or less, its status is “Dead” and cannot attack anymore.  Hellion o Range is 5 o Attack deals 8 damage o Maxhp is 90 o Hellions cannot attack flying units  Siege Tank o Range is 7 o Attack deals 15 damage o Maxhp is 160 o Siege Tanks cannot attack flying units o Siege Tanks have a siegeMode function  Status is set to “Siege”  Range is now 13 and damage from attacks is now 35  However you cannot attack targets that are within 2 distance o Siege Tanks also have a function normalMode where status is back to “Normal”, range and damage are also returned to normal  Thor o Range is 7 o Attack damage is 30 o Maxhp is 400
  • 4.
    Ship Units  All ships units are flying  Not all ships can attack  If a ship’s hp is 0 or less, its status is “Dead” and cannot attack anymore.  Viking o Range is 9 o Attack deals 12 damage o Maxhp is 120 o Can only attack flying units  Medivac o Cannot attack units o Maxhp is 150 o Has an attribute, cargo which is an array of units (size 6) o Has a load(unit) function which adds the unit to the array o Has unload(int) function which returns the unit at the int index of the array o If the Medivac moves, the units in cargo moves with it o Meduvacs have an attribute SP initially at 200 o Medivac can also heal(Target)  Increases Target’s hp by 3, not exceeding the maxhp as long as SP is greater than 0.  Decreases hp by 1.  Banshee o Range is 6 o Attack deals 12 damage o Maxhp is 140 o Has an attribute SP, similar to ghosts o Cannot attack other ships o Can cloak, similar to ghosts  Battlecruiser o Range is 6 o Attack deals 8 damage o Maxhp is 550 o Has an attribute SP which is initially 250 o Has a function weaponRefit(Target)  Deals 300 damage to the target as long as SP is greater than or equal to 125  Decreases SP by 125  Range is 10
  • 5.
    Buildings  CommandCenter o Maxhp is 1500 o Has function trainSCV, which returns an SCV object  Barracks o Maxhp is 1000 o Has functions:  trainMarine, which returns a Marine object  trainMarauder, which returns a Marauder object  trainGhost, which returns a Ghost object  Factory o Maxhp is 1250 o Has functions:  trainHellion, which returns a Hellion object  trainSiegeTank, which returns a SiegeTank object  trainThor, which returns a Thor object  Starport o Maxhp is 1300 o Has functions:  trainViking, which returns a Viking object  trainMedivac, which returns a Medivac object  trainBanshee, which returns a Banshee object  trainBattlecruise, which returns a Battlecruiser object BONUS FUNCTIONS  Buildings have the ability liftoff (5 pts) o Status is set to “Flying” o While flying only units that can attack flying units can attack it  Buildings also have ability to land (5 pts) o Status is set to “Normal” o While flying only units that can attack ground units can attack it  Vikings also have the ability to lift-off and land (5 pts) o While flying, Vikings can only attack flying units o While landed, Vikings can only attack units that are not flying  Hellions deal 16 damage to Infantry units (5 pts)  If a Medivac dies, all unit inside it also dies (5 pts)  Output a message (System.out.println) whenever an attack is successful or not. (5 pts)