Created
June 5, 2014 04:15
-
-
Save cdduarte/a7ff6a285c2b7d2fc26d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Driver - Driver for implementation of generic Hash Table class, | |
* similar to Java HashMap<K,V> class. | |
* | |
* @author christopherduarte | |
* @reference professor robertirwin | |
* | |
* CIS551 | |
* Lab16 | |
*/ | |
class MyItem<Key> implements KeyedValue<Key> | |
{ | |
Key key; | |
String name; | |
int age; | |
MyItem( Key k, String n, int a) { | |
key = k; | |
name = n; | |
age = a; | |
} | |
public Key getKey() { | |
return key; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public int getAge() { | |
return age; | |
} | |
public void setAge(int age) { | |
this.age = age; | |
} | |
public String toString() { | |
return "item with key " + getKey() + ": \n" + | |
"\tKey: " + getKey() + "\n" + | |
"\tName: " + getName() + "\n" + | |
"\tAge: " + getAge(); | |
} | |
} | |
public class Driver { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) | |
{ | |
MyHashMap<String,MyItem<String>> t = new MyHashMap<String,MyItem<String>>(); | |
MyItem<String> i = new MyItem<String>("123456789","Joe Schmoe",49); | |
MyItem<String> j = new MyItem<String>("987654321","Ajay Bloosh",23); | |
MyItem<String> k = new MyItem<String>("101010101","Tara Boomdeay",30); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment