Class CityContract


  • public class CityContract
    extends Contract
    Class containing all information about contracts between two cities
    Author:
    Klara Schöbel
    • Constructor Summary

      Constructors 
      Constructor Description
      CityContract​(java.lang.String id, int value, City cityA, City cityB)
      constructs a contract between two cities with an id, and a value
    • Constructor Detail

      • CityContract

        public CityContract​(java.lang.String id,
                            int value,
                            City cityA,
                            City cityB)
        constructs a contract between two cities with an id, and a value
        Parameters:
        id - id of the contract (see also Contract.getCID())
        value - value of the Contract (see also Contract.getValue())
        cityA - "starting" city of the route specified by this contract (see also getCityA())
        cityB - "ending" city of the route specified by this contract (see also getCityB())
    • Method Detail

      • getCityA

        public City getCityA()
        getter for cityA
        Returns:
        cityA
      • getCityB

        public City getCityB()
        getter for CityB
        Returns:
        cityB
      • equals

        public boolean equals​(java.lang.Object o)
        Override for the equals() method of java.lang.object to match the logic behind cityContracts.

        Two city contracts are equal if they have the same cities

        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - object it could be equal to
        Returns:
        if this object is equal to object o
      • hashCode

        public int hashCode()
        override for hashCode() of java.lang.object
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        our hash of the city obtained by name of cityA + "/" + name of cityB