CSC212 Lab 5 2014

From dftwiki3
Revision as of 15:55, 23 September 2014 by Thiebaut (talk | contribs)
Jump to: navigation, search

--D. Thiebaut (talk) 16:12, 23 September 2014 (EDT)


Problem 1


public class Pair<T, P> {
    private T first;
    private P second;

    public Pair( T f, P s ) {
        first = f;
        second = s;
    }

    public T getFirst() { return first; }
    public P getSecond() { return second; }
    public void setFirst( T f ) { first = f; }
    public void setSecond( P s ) { second = s; }
    public String toString( ) { return "(" + first + ", " + second + ")"; }
}
  1. Change ints for doubles
  2. change ints for String
  3. change for String, double
  4. create array of 10 String, double
  5. create a generic class for triplet
  6. create array of 10 triplets( )
  7. exception:
  1. secure some pieces of code with try catch
  2. throw