-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pair
73 lines (59 loc) · 1.49 KB
/
Pair
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
///<Pair> Use generic class to print pair
//CSIS312 - <Assignment 7>
//Citations if necessary>--
package pair;
/**
*
* @author lirby
*/
public class Pair <F,S>{
//variables
private F first;
private S second;
//constructor
public Pair(F first, S second){
this.first
= first;
this.second = second;
}
//setters
public void setFirst(F first) {
this.first = first;
}
public void setSecond(S second){
this.second = second;
}
//getters
public F getFirst(){
return first;
}
public S getSecond(){
return second;
}
}//end class
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pair;
/**
*
* @author lirby
*/
public class PairTest {
public static void main(String[] args) {
// TODO code application logic here
//required class line
System.out.println("Lisa Tidball - Assignment 7");
//pairs
Pair<Integer, String> p1 = new Pair<>(7, "March");
Pair<String, Integer> p2 = new Pair<>("May", 9);
//print first pair
System.out.printf("%s,%s", p1.getFirst(), p1.getSecond());
System.out.println();
//print second pair
System.out.printf("%s,%s", p2.getFirst(), p2.getSecond());
System.out.println();
}
}