//Main class for Bermuda Triangle Program
//by www.neiljohan.com

import java.util.*;

public class PositionImpl implements Position
{
    private double tLongDegrees, tLongMinutes, tLatDegrees, tLatMinutes;
    private char tLongDirection, tLatDirection;

        //Co-ordinate in the form of 64-32
    
    public PositionImpl (final String tInput)
        {
            StringTokenizer tTokensOnLine = new StringTokenizer(tInput, "-");

            String tThisToken = tTokensOnLine.nextToken();
            tLongDegrees = new Double(tThisToken).doubleValue();

            tThisToken = tTokensOnLine.nextToken();
            tLongMinutes = new Double(tThisToken).doubleValue();

            tThisToken = tTokensOnLine.nextToken();
            tLongDirection = tThisToken.charAt(0);


            tThisToken = tTokensOnLine.nextToken();
            tLatDegrees = new Double(tThisToken).doubleValue();

            tThisToken = tTokensOnLine.nextToken();
            tLatMinutes = new Double(tThisToken).doubleValue();

            tThisToken = tTokensOnLine.nextToken();
            tLatDirection = tThisToken.charAt(0);

            
            
        }

    public double getLongitude()
        {
            return tLongDegrees;
        }

    public double getLongMinutes()
        {
            return tLongMinutes;
        }

    public char getLongDirection()
        {
            return tLongDirection;
        }
    
    

    public double getLatitude()
        {
            return tLatDegrees;
        }

  public double getLatMinutes()
        {
            return tLatMinutes;
        }
       
 public char getLatDirection()
        {
            return tLatDirection;
        }


    public void setLongitude(final double newLat)
        {
            tLongDegrees = newLat;
        }

    public void setLatitude(final double newLong)
        {
            tLatDegrees = newLong;
        }

    public String toString()
        {
            return "" + tLongDegrees + tLatDegrees;
        }

    public int hashCode()
        {
            String Long = Double.toString(tLongDegrees);
            String Lat = Double.toString(tLatDegrees);
            int iLong = new Integer(Long).intValue();
            int iLat = new Integer(Lat).intValue();
            return iLong*360 + iLat*60;
        }

    public boolean equals(final Object pObject)
        {
            if (! (pObject instanceof PositionImpl)){
                return false;
            }
            {
                return tLongDegrees==((PositionImpl)pObject).tLongDegrees && tLatDegrees==((PositionImpl)pObject).tLatDegrees;
            }
        }
}

