Main Content

The spirit of Java - delegating to classes

Archive - Originally posted on "The Horse's Mouth" - 2015-02-18 17:00:01 - Graham Ellis

Building up towards the end of a Java course, I've been very much teaching the spirit of Java where code is delegated to classes and leaves the main application as a few short method calls, making it readable in its own right, and allowing code that uses the same data type to be shared between programs. Here's my main program:

  import java.util.*;
  
  public class Framework {
  
  public static void main (String [] args) {
  
    MyStream StationSource = new MyStream("rstats2014.xyz");
    HashMap NationalRail = Station.factory(StationSource);
    System.out.println(NationalRail.get("LAS"));
  
    ArrayList Codes = MyUtils.sortedList(NationalRail);
    MyUtils.print(NationalRail,Codes);
  
    }
  }


Complete code for this (and the three classes used) [here] and an earlier stage [here].