Skip to content

Instantly share code, notes, and snippets.

@cdduarte
Created June 5, 2014 04:15
Show Gist options
  • Save cdduarte/a7ff6a285c2b7d2fc26d to your computer and use it in GitHub Desktop.
Save cdduarte/a7ff6a285c2b7d2fc26d to your computer and use it in GitHub Desktop.
/**
* 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