Difference between revisions of "CSC212 Lab 5 2014"

From dftwiki3
Jump to: navigation, search
(Created page with "--~~~~ ---- =Problem 1= <br /> <source lang="java"> public class Pair<T, P> { private T first; private P second; public Pair( T f, P s ) { first = f; ...")
 
Line 21: Line 21:
  
 
</source>
 
</source>
 +
 +
# Change ints for doubles
 +
# change ints for String
 +
# change for String, double
 +
# create array of 10 String, double
 +
# create a generic class for triplet
 +
# create array of 10 triplets(  )
 +
# exception:
 +
:#  secure some pieces of code with try catch
 +
:#  throw

Revision as of 15:55, 23 September 2014

--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