Class CaptainState

  • All Implemented Interfaces:
    ICaptain, IPerson

    @Component
    @Scope("prototype")
    public class CaptainState
    extends java.lang.Object
    implements ICaptain
    Implementation of the captain.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2013 Created on Jan 26, 2013
    • Constructor Detail

      • CaptainState

        public CaptainState()
    • Method Detail

      • getAge

        public int getAge()
        Description copied from interface: ICaptain
        Current age of the captain
        Specified by:
        getAge in interface ICaptain
        Returns:
        age of the captain
      • getName

        public java.lang.String getName()
        Description copied from interface: ICaptain
        Retrieve the name of the captain
        Specified by:
        getName in interface ICaptain
        Returns:
        name of the captain
      • getSalary

        public int getSalary()
        Description copied from interface: ICaptain
        Retrieve the salary per day.
        Specified by:
        getSalary in interface ICaptain
        Returns:
        salaray of the captain
      • getTradingSkillLevel

        public int getTradingSkillLevel()
        Description copied from interface: ICaptain
        Retrieve the level in trading between [0,5]
        Specified by:
        getTradingSkillLevel in interface ICaptain
        Returns:
        trading skill of the captain.
      • getNavigationSkillLevel

        public int getNavigationSkillLevel()
        Description copied from interface: ICaptain
        Retrieve the level in navigation between [0,5]
        Specified by:
        getNavigationSkillLevel in interface ICaptain
        Returns:
        navigation skill of the captain
      • getFightSkillLevel

        public int getFightSkillLevel()
        Description copied from interface: ICaptain
        Retrieve the level in sea fights between [0,5]
        Specified by:
        getFightSkillLevel in interface ICaptain
        Returns:
        fighting skill of the captain.
      • setSalary

        public void setSalary​(int salary)
        Set the new salary
        Parameters:
        salary - salary of the captain.
      • assignToShip

        public void assignToShip​(IShip ship)
        Description copied from interface: ICaptain
        Assign a captain to a ship.
        Specified by:
        assignToShip in interface ICaptain
        Parameters:
        ship - to which the captain is assigned.
      • getAssignedShip

        public java.util.Optional<IShip> getAssignedShip()
        Get the ship the captain is assigned to.
        Specified by:
        getAssignedShip in interface ICaptain
        Returns:
        absent if the captain is not assigned to any ship.
      • upgradeToNextTradeLevel

        public boolean upgradeToNextTradeLevel()
        Description copied from interface: ICaptain
        Increase the experiance level by one. The highest level i 5.
        Specified by:
        upgradeToNextTradeLevel in interface ICaptain
        Returns:
        true if upgrade happened.
      • updateProfit

        public void updateProfit​(int profit)
        Description copied from interface: ICaptain
        Add the profit the total profit.
        Specified by:
        updateProfit in interface ICaptain
        Parameters:
        profit - additional profit
      • updatedSailedDistance

        public void updatedSailedDistance​(int distance)
        Description copied from interface: ICaptain
        Add the sailed distance to the total
        Specified by:
        updatedSailedDistance in interface ICaptain
        Parameters:
        distance - additional distance
      • upgradeToNextNavigationLevel

        public boolean upgradeToNextNavigationLevel()
        Description copied from interface: ICaptain
        If possible upgrade the captain to the next level on navigation skill.
        Specified by:
        upgradeToNextNavigationLevel in interface ICaptain
        Returns:
        true if upgrade happened
      • updateFightWon

        public void updateFightWon()
        Description copied from interface: ICaptain
        Increase the number of won fights.
        Specified by:
        updateFightWon in interface ICaptain
      • upgradeToNextFightingLevel

        public boolean upgradeToNextFightingLevel()
        Description copied from interface: ICaptain
        If possible upgrade the captain fight skill to the next level.
        Specified by:
        upgradeToNextFightingLevel in interface ICaptain
        Returns:
        true if an upgrade happened