CSE-8B / PA8 / starter / Position.java
Position.java
Raw
//File: Position.java
//Name: Trai Pham
//Date: 03/02/2020
//Course: CSE 8B
/**
Holds thep position of a Pokemon in a box, in a storage system.
**/

public class Position<T>{
//represents the pokemon that is currently at the position
  private T pokemon;

/**
@param T type
@return nothing
Constructor
**/
  public Position(T pokemon){
    this.pokemon = pokemon;
  }

/**
@param nothing
@return T type
getter method that gets the pokemon in a position
**/
  public T getPokemon(){
    return this.pokemon;
  }

/**
@param T type
@return nothing
Sets the a new pokemon of type T to a position
**/
  public void setPokemon(T newPokemon){
    this.pokemon = newPokemon;
  }

/**
@param nothing
@return boolean
Checks if the position is free or not
**/
  public boolean isOpen(){
//check if there's a pokemon in the current position.
    if(this.pokemon == null){
      return true;
    }
    else{
      return false;
    }
  }
}