Class Metrics


  • public class Metrics
    extends java.lang.Object
    Metrics aka Resources. This class will be used for multiple metrics values relevant to the game.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      double food
      food component of the metrics/resources
      double materials
      materials component of the metrics/resources
      double money
      money component of the metrics/resources
    • Constructor Summary

      Constructors 
      Constructor Description
      Metrics()
      Create empty metrics object.
      Metrics​(Metrics other)
      Copy the metrics
    • Field Detail

      • food

        public double food
        food component of the metrics/resources
      • materials

        public double materials
        materials component of the metrics/resources
      • money

        public double money
        money component of the metrics/resources
    • Constructor Detail

      • Metrics

        public Metrics()
        Create empty metrics object.
      • Metrics

        public Metrics​(Metrics other)
        Copy the metrics
        Parameters:
        other - metrics to copy
    • Method Detail

      • deserialize

        public static Metrics deserialize​(org.json.JSONObject data)
        deserializes metrics from a json object.
        Parameters:
        data - json data
        Returns:
        deserialized metrics
      • serialize

        public org.json.JSONObject serialize()
        serializes Metrics to json
        Returns:
        json object
      • getFood

        public double getFood()
        get food component.
        Returns:
        amount
      • getMaterials

        public double getMaterials()
        get materials component.
        Returns:
        amount
      • getMoney

        public double getMoney()
        get money component
        Returns:
        amount
      • isSmallerEqThen

        public boolean isSmallerEqThen​(Metrics other)
        Check is the metrics are smaller or equal than another metrics object.
        Parameters:
        other - to compare to
        Returns:
        if is smaller/equal
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clone

        public Metrics clone()
        Overrides:
        clone in class java.lang.Object