title: Determining the range of year in a linked list
body: <p>Hello i'm trying to determine the range of years from a linked list and i need help. To achieve this i have 2 variables called minYear and maxYear in my container class that holds the subscriptionYears linked list. The SubscriptionYear reads the year and the cellular data for that year. Class country stores the country name and is the container for the linked list subscriptionYear that stores the year and cellular data for each country.</p>
  
  <p>The minYear is set to 9999. and maxYear is set to 0. Every time i add a subscription to the list i update the minYear and maxYear. And i use the "minYear" and "maxYear" to check if the requested subscription period is valid. How do i implement the minYear and maxYear to check if the requested subscription is valid. </p>
  
  <p>My class Subscriptionyear stores the year and cellular data for that particular year as a double.</p>
  
  <pre><code>//stores the year and statistical subscription data for that year
  public class SubscriptionYear {
  
  private int year;
  private double subscriptions;
  SubscriptionYear next;
  
  public SubscriptionYear(int year,double subscriptions)
  {
      setYear(year);
      setSubscription(subscriptions);
      this.next = null;
  }
  public void setYear(int Year)
  {
      this.year= Year;
  }
  public void setSubscription(double value)
  {
      this.subscriptions = value;
  }
  public int getYear()
  {
      return year;
  }
  public double getSubscription()
  {
      return subscriptions;
  }
  public String toString()
  {
      return "Number of Subscriptions: "+subscriptions;
  }
  public void setNode(SubscriptionYear next)
  {
      this.next = next;
  }
  public SubscriptionYear getNext()
  {
      return this.next;
  }
  }
  </code></pre>
  
  <p>class Country: My class Country stores the name of the country and acts a container for linked list of susbcriptionYear that contains the year and stat information for that country. I was able to create the list and successfully print the list but i cannot seem to get the problem solved above. The stats data begins from 1960 to 2012. </p>
  
  <pre><code>public class Country  {
  
  private String countryNames;
  private SubscriptionYear subscriptions;
  private int minYear;
  private int maxYear;
  
  public Country(String country)
  {
      this.countryNames = country;
      this.subscriptions = null;
      this.maxYear = 0;
      this.minYear = 9999;
      }
  
  //adds the subscription and updates the minYear and maxYear
  //Dont think i set up the minYear and maxYear correctly.
  public void addSubscriptionYear(int year, double subscription)
  {
      SubscriptionYear newNode = new SubscriptionYear(year, subscription);
      if(this.isEmpty())
      {
          newNode.setNode(subscriptions);
          subscriptions = newNode;
          if(newNode.getYear()==1960)
          {
              this.minYear++;
          }
      }
      else{
          SubscriptionYear current = subscriptions;
          while(current.getNext()!=null)
          {
              if(current.getYear()==1960)
              {
                  this.minYear++;
              }
             else if(current.getYear()==2012)
             {
                this.maxYear++
             }
           current = current.getNext();
          }
          current.setNode(newNode);   
      }
  }
  
  //overrides the toString method and prints out the countries.
  public String toString()
  {
      String result="";
      result += "\n"+this.countryNames;
      SubscriptionYear current = subscriptions;
      while(current!=null)
      {
          result+="\t"+current.getSubscription();
          current = current.getNext();        
      }
      return result;
  }
   //returns countryName
    public String getName()
  {
      return this.countryNames;
  }
  public boolean isEmpty()
  {
      return (subscriptions == null);
  }
  }
  </code></pre>