SlideShare a Scribd company logo
In this assignment, you will implement a generic map interface
in two ways:
as a hash table
with another map implementation from the activity (attached)
If you prefer, you may implement and test maps of Strings
(sample code in the right column below).
You should use normal Java arrays for storage, not ArrayList or
other classes from the Java Collections API.
Your submission should be a zip file
that includes the following files:
IMap.java (below, no changes needed)
IMapTest.java, HashMapTest.java, and OtherMapTest.java
(below, no changes needed)
use the first column for Generic version, second column for
String version
HashMap.java (your hash table implementation)
(Here is the main task)
OtherMap.java (your other implementation)
(Here is the main task)
Sample Code for Generics
Sample Code for Strings (not Generic)
interface IMap {
boolean del (int key); // delete key & its value
T get (int key); // get value for key
boolean put (int key, T val); // put key,value in map
boolean hasKey(int key); // is key in map?
boolean hasVal(T val); // is val in map?
void clear (); // remove all keys & values
String dump (); // return String with contents
int size (); // return # of pairs
}
interface IMap {
boolean del (int key); // delete key & its value
String get (int key); // get value for key
boolean put (int key, String val); // put key,value in map
boolean hasKey(int key); // is key in map?
boolean hasVal(String val); // is val in map?
void clear (); // remove all keys & values
String dump (); // return String with contents
int size (); // return # of pairs
}
import static org.junit.Assert.*;
import org.junit.*;
public abstract class IMapTest {
protected IMap map;
// each subclass should initialize map and then call
super.before()
public void before() {
assertNotNull(this.map);
this.map.put(1,"one");
}
@After
public void after() {
this.map = null;
}
@Test
public void constructor() {
assertNotNull(this.map);
}
@Test
public void clear() {
assertEquals(1, this.map.size());
this.map.clear();
assertEquals(0, this.map.size());
}
@Test
public void del() {
assertEquals(1, this.map.size());
assertFalse ( this.map.del(0));
assertTrue ( this.map.del(1));
assertFalse ( this.map.del(1));
assertEquals(0, this.map.size());
}
@Test
public void get() {
assertNull ( this.map.get(0));
assertEquals("one", this.map.get(1));
}
@Test
public void has() {
assertTrue (this.map.hasKey(1));
assertTrue (this.map.hasVal("one"));
assertFalse(this.map.hasKey(3));
assertFalse(this.map.hasVal("three"));
assertTrue (this.map.put(3,"three"));
assertTrue (this.map.hasKey(3));
assertTrue (this.map.hasVal("three"));
}
@Test
public void put() {
assertEquals(1, this.map.size());
assertFalse ( this.map.put(1,"one"));
assertTrue ( this.map.put(3,"three"));
assertFalse ( this.map.put(3,"three"));
assertEquals(2, this.map.size());
}
}
import static org.junit.Assert.*;
import org.junit.*;
public abstract class IMapTest {
protected IMap map;
// each subclass should initialize map and then call
super.before()
public void before() {
assertNotNull(this.map);
this.map.put(1,"one");
}
@After
public void after() {
this.map = null;
}
@Test
public void constructor() {
assertNotNull(this.map);
}
@Test
public void clear() {
assertEquals(1, this.map.size());
this.map.clear();
assertEquals(0, this.map.size());
}
@Test
public void del() {
assertEquals(1, this.map.size());
assertFalse ( this.map.del(0));
assertTrue ( this.map.del(1));
assertFalse ( this.map.del(1));
assertEquals(0, this.map.size());
}
@Test
public void get() {
assertNull ( this.map.get(0));
assertEquals("one", this.map.get(1));
}
@Test
public void has() {
assertTrue (this.map.hasKey(1));
assertTrue (this.map.hasVal("one"));
assertFalse(this.map.hasKey(3));
assertFalse(this.map.hasVal("three"));
assertTrue (this.map.put(3,"three"));
assertTrue (this.map.hasKey(3));
assertTrue (this.map.hasVal("three"));
}
@Test
public void put() {
assertEquals(1, this.map.size());
assertFalse ( this.map.put(1,"one"));
assertTrue ( this.map.put(3,"three"));
assertFalse ( this.map.put(3,"three"));
assertEquals(2, this.map.size());
}
}
import static org.junit.Assert.*;
import org.junit.*;
public class HashMapTest extends IMapTest {
@Before
public void before() {
this.map = new HashMap(10);
super.before();
}
}
import static org.junit.Assert.*;
import org.junit.*;
public class HashMapTest extends IMapTest {
@Before
public void before() {
this.map = new HashMap(10);
super.before();
}
}
import static org.junit.Assert.*;
import org.junit.*;
public class OtherMapTest extends IMapTest {
@Before
public void before() {
this.map = new OtherMap(10);
super.before();
}
}
import static org.junit.Assert.*;
import org.junit.*;
public class OtherMapTest extends IMapTest {
@Before
public void before() {
this.map = new OtherMap(10);
super.before();
}
}

More Related Content

Similar to In this assignment, you will implement a generic map interface in tw.docx

java write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdfjava write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdf
arjuntelecom26
 
Please review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdfPlease review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdf
fathimafancyjeweller
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
aromanets
 
Laporan ai modul 2-if b 2014-14102055-deprilana ego prakasa
Laporan ai modul 2-if b 2014-14102055-deprilana ego prakasaLaporan ai modul 2-if b 2014-14102055-deprilana ego prakasa
Laporan ai modul 2-if b 2014-14102055-deprilana ego prakasa
Deprilana Ego Prakasa
 
Complete the implementation of the Weighted Graph that we began in t.pdf
Complete the implementation of the Weighted Graph that we began in t.pdfComplete the implementation of the Weighted Graph that we began in t.pdf
Complete the implementation of the Weighted Graph that we began in t.pdf
marketing413921
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdf
mohdjakirfb
 
ScalaFlavor4J
ScalaFlavor4JScalaFlavor4J
ScalaFlavor4J
Kazuhiro Sera
 
Java Question help needed In the program Fill the Add statements.pdf
Java Question  help needed In the program Fill the Add statements.pdfJava Question  help needed In the program Fill the Add statements.pdf
Java Question help needed In the program Fill the Add statements.pdf
kamdinrossihoungma74
 
Write a program that reads a graph from a file and determines whether.docx
 Write a program that reads a graph from a file and determines whether.docx Write a program that reads a graph from a file and determines whether.docx
Write a program that reads a graph from a file and determines whether.docx
ajoy21
 
1 Part I written exercises.1. Using the Red-Black Tre.docx
1 Part I written exercises.1. Using the Red-Black Tre.docx1 Part I written exercises.1. Using the Red-Black Tre.docx
1 Part I written exercises.1. Using the Red-Black Tre.docx
mercysuttle
 
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfUsing NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
siennatimbok52331
 
Internal workshop es6_2015
Internal workshop es6_2015Internal workshop es6_2015
Internal workshop es6_2015
Miguel Ruiz Rodriguez
 
Java 5 Features
Java 5 FeaturesJava 5 Features
Java 5 Features
sholavanalli
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdf
anushkaent7
 
JavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programmingJavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programming
Henri Tremblay
 
Array list
Array listArray list
Array list
vishal choudhary
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
ARCHANASTOREKOTA
 
Oop lecture9 13
Oop lecture9 13Oop lecture9 13
Oop lecture9 13
Shahriar Robbani
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
Jussi Pohjolainen
 
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docxMETA-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
andreecapon
 

Similar to In this assignment, you will implement a generic map interface in tw.docx (20)

java write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdfjava write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdf
 
Please review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdfPlease review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdf
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
 
Laporan ai modul 2-if b 2014-14102055-deprilana ego prakasa
Laporan ai modul 2-if b 2014-14102055-deprilana ego prakasaLaporan ai modul 2-if b 2014-14102055-deprilana ego prakasa
Laporan ai modul 2-if b 2014-14102055-deprilana ego prakasa
 
Complete the implementation of the Weighted Graph that we began in t.pdf
Complete the implementation of the Weighted Graph that we began in t.pdfComplete the implementation of the Weighted Graph that we began in t.pdf
Complete the implementation of the Weighted Graph that we began in t.pdf
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdf
 
ScalaFlavor4J
ScalaFlavor4JScalaFlavor4J
ScalaFlavor4J
 
Java Question help needed In the program Fill the Add statements.pdf
Java Question  help needed In the program Fill the Add statements.pdfJava Question  help needed In the program Fill the Add statements.pdf
Java Question help needed In the program Fill the Add statements.pdf
 
Write a program that reads a graph from a file and determines whether.docx
 Write a program that reads a graph from a file and determines whether.docx Write a program that reads a graph from a file and determines whether.docx
Write a program that reads a graph from a file and determines whether.docx
 
1 Part I written exercises.1. Using the Red-Black Tre.docx
1 Part I written exercises.1. Using the Red-Black Tre.docx1 Part I written exercises.1. Using the Red-Black Tre.docx
1 Part I written exercises.1. Using the Red-Black Tre.docx
 
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfUsing NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
 
Internal workshop es6_2015
Internal workshop es6_2015Internal workshop es6_2015
Internal workshop es6_2015
 
Java 5 Features
Java 5 FeaturesJava 5 Features
Java 5 Features
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdf
 
JavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programmingJavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programming
 
Array list
Array listArray list
Array list
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
 
Oop lecture9 13
Oop lecture9 13Oop lecture9 13
Oop lecture9 13
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docxMETA-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
 

More from widdowsonerica

Information Technology, Computer Networks and CyberspaceKizza (201.docx
Information Technology, Computer Networks and CyberspaceKizza (201.docxInformation Technology, Computer Networks and CyberspaceKizza (201.docx
Information Technology, Computer Networks and CyberspaceKizza (201.docx
widdowsonerica
 
Information to use for paperStep 1 Select your topic and focus.docx
Information to use for paperStep 1 Select your topic and focus.docxInformation to use for paperStep 1 Select your topic and focus.docx
Information to use for paperStep 1 Select your topic and focus.docx
widdowsonerica
 
Information and Knowledge Needs of Nurses in the 21st CenturyIn th.docx
Information and Knowledge Needs of Nurses in the 21st CenturyIn th.docxInformation and Knowledge Needs of Nurses in the 21st CenturyIn th.docx
Information and Knowledge Needs of Nurses in the 21st CenturyIn th.docx
widdowsonerica
 
Infectious and Noninfectious Prevention and Control TechniquesIn.docx
Infectious and Noninfectious Prevention and Control TechniquesIn.docxInfectious and Noninfectious Prevention and Control TechniquesIn.docx
Infectious and Noninfectious Prevention and Control TechniquesIn.docx
widdowsonerica
 
Information Management and Software Development Please respo.docx
Information Management and Software Development Please respo.docxInformation Management and Software Development Please respo.docx
Information Management and Software Development Please respo.docx
widdowsonerica
 
Information Security  Please respond to the followingIdentify t.docx
Information Security  Please respond to the followingIdentify t.docxInformation Security  Please respond to the followingIdentify t.docx
Information Security  Please respond to the followingIdentify t.docx
widdowsonerica
 
Information PaperThe Chief of Staff is preparing preliminary studi.docx
Information PaperThe Chief of Staff is preparing preliminary studi.docxInformation PaperThe Chief of Staff is preparing preliminary studi.docx
Information PaperThe Chief of Staff is preparing preliminary studi.docx
widdowsonerica
 
INF 410 week 4 assign onAssume you are the project manager for a s.docx
INF 410 week 4 assign onAssume you are the project manager for a s.docxINF 410 week 4 assign onAssume you are the project manager for a s.docx
INF 410 week 4 assign onAssume you are the project manager for a s.docx
widdowsonerica
 
Information Technology in Public HealthPublic health surveillance .docx
Information Technology in Public HealthPublic health surveillance .docxInformation Technology in Public HealthPublic health surveillance .docx
Information Technology in Public HealthPublic health surveillance .docx
widdowsonerica
 
Information System and Enterprise SystemsIdentify the key factors.docx
Information System and Enterprise SystemsIdentify the key factors.docxInformation System and Enterprise SystemsIdentify the key factors.docx
Information System and Enterprise SystemsIdentify the key factors.docx
widdowsonerica
 
Individuals react to a variety of social cues to construct their per.docx
Individuals react to a variety of social cues to construct their per.docxIndividuals react to a variety of social cues to construct their per.docx
Individuals react to a variety of social cues to construct their per.docx
widdowsonerica
 
Information Technology and Decision MakingPatient safety and care .docx
Information Technology and Decision MakingPatient safety and care .docxInformation Technology and Decision MakingPatient safety and care .docx
Information Technology and Decision MakingPatient safety and care .docx
widdowsonerica
 
Individuals use social movements when they feel a social institution.docx
Individuals use social movements when they feel a social institution.docxIndividuals use social movements when they feel a social institution.docx
Individuals use social movements when they feel a social institution.docx
widdowsonerica
 
Industry Averages and Financial Ratios PaperCalculate the 14 rat.docx
Industry Averages and Financial Ratios PaperCalculate the 14 rat.docxIndustry Averages and Financial Ratios PaperCalculate the 14 rat.docx
Industry Averages and Financial Ratios PaperCalculate the 14 rat.docx
widdowsonerica
 
Information is provided for you below that will help you construct a.docx
Information is provided for you below that will help you construct a.docxInformation is provided for you below that will help you construct a.docx
Information is provided for you below that will help you construct a.docx
widdowsonerica
 
Individuals who are frequent voters share common characteristics, re.docx
Individuals who are frequent voters share common characteristics, re.docxIndividuals who are frequent voters share common characteristics, re.docx
Individuals who are frequent voters share common characteristics, re.docx
widdowsonerica
 
Infectious diseases come with extremely tough challenges to mitigate.docx
Infectious diseases come with extremely tough challenges to mitigate.docxInfectious diseases come with extremely tough challenges to mitigate.docx
Infectious diseases come with extremely tough challenges to mitigate.docx
widdowsonerica
 
Individual Reflection in which you describe the plan that you would .docx
Individual Reflection in which you describe the plan that you would .docxIndividual Reflection in which you describe the plan that you would .docx
Individual Reflection in which you describe the plan that you would .docx
widdowsonerica
 
Individual ProjectGroups in the WorkplaceSun, 10816.docx
Individual ProjectGroups in the WorkplaceSun, 10816.docxIndividual ProjectGroups in the WorkplaceSun, 10816.docx
Individual ProjectGroups in the WorkplaceSun, 10816.docx
widdowsonerica
 
Individual ProjectRecruitment Strategies and Tools Mon, 83.docx
Individual ProjectRecruitment Strategies and Tools Mon, 83.docxIndividual ProjectRecruitment Strategies and Tools Mon, 83.docx
Individual ProjectRecruitment Strategies and Tools Mon, 83.docx
widdowsonerica
 

More from widdowsonerica (20)

Information Technology, Computer Networks and CyberspaceKizza (201.docx
Information Technology, Computer Networks and CyberspaceKizza (201.docxInformation Technology, Computer Networks and CyberspaceKizza (201.docx
Information Technology, Computer Networks and CyberspaceKizza (201.docx
 
Information to use for paperStep 1 Select your topic and focus.docx
Information to use for paperStep 1 Select your topic and focus.docxInformation to use for paperStep 1 Select your topic and focus.docx
Information to use for paperStep 1 Select your topic and focus.docx
 
Information and Knowledge Needs of Nurses in the 21st CenturyIn th.docx
Information and Knowledge Needs of Nurses in the 21st CenturyIn th.docxInformation and Knowledge Needs of Nurses in the 21st CenturyIn th.docx
Information and Knowledge Needs of Nurses in the 21st CenturyIn th.docx
 
Infectious and Noninfectious Prevention and Control TechniquesIn.docx
Infectious and Noninfectious Prevention and Control TechniquesIn.docxInfectious and Noninfectious Prevention and Control TechniquesIn.docx
Infectious and Noninfectious Prevention and Control TechniquesIn.docx
 
Information Management and Software Development Please respo.docx
Information Management and Software Development Please respo.docxInformation Management and Software Development Please respo.docx
Information Management and Software Development Please respo.docx
 
Information Security  Please respond to the followingIdentify t.docx
Information Security  Please respond to the followingIdentify t.docxInformation Security  Please respond to the followingIdentify t.docx
Information Security  Please respond to the followingIdentify t.docx
 
Information PaperThe Chief of Staff is preparing preliminary studi.docx
Information PaperThe Chief of Staff is preparing preliminary studi.docxInformation PaperThe Chief of Staff is preparing preliminary studi.docx
Information PaperThe Chief of Staff is preparing preliminary studi.docx
 
INF 410 week 4 assign onAssume you are the project manager for a s.docx
INF 410 week 4 assign onAssume you are the project manager for a s.docxINF 410 week 4 assign onAssume you are the project manager for a s.docx
INF 410 week 4 assign onAssume you are the project manager for a s.docx
 
Information Technology in Public HealthPublic health surveillance .docx
Information Technology in Public HealthPublic health surveillance .docxInformation Technology in Public HealthPublic health surveillance .docx
Information Technology in Public HealthPublic health surveillance .docx
 
Information System and Enterprise SystemsIdentify the key factors.docx
Information System and Enterprise SystemsIdentify the key factors.docxInformation System and Enterprise SystemsIdentify the key factors.docx
Information System and Enterprise SystemsIdentify the key factors.docx
 
Individuals react to a variety of social cues to construct their per.docx
Individuals react to a variety of social cues to construct their per.docxIndividuals react to a variety of social cues to construct their per.docx
Individuals react to a variety of social cues to construct their per.docx
 
Information Technology and Decision MakingPatient safety and care .docx
Information Technology and Decision MakingPatient safety and care .docxInformation Technology and Decision MakingPatient safety and care .docx
Information Technology and Decision MakingPatient safety and care .docx
 
Individuals use social movements when they feel a social institution.docx
Individuals use social movements when they feel a social institution.docxIndividuals use social movements when they feel a social institution.docx
Individuals use social movements when they feel a social institution.docx
 
Industry Averages and Financial Ratios PaperCalculate the 14 rat.docx
Industry Averages and Financial Ratios PaperCalculate the 14 rat.docxIndustry Averages and Financial Ratios PaperCalculate the 14 rat.docx
Industry Averages and Financial Ratios PaperCalculate the 14 rat.docx
 
Information is provided for you below that will help you construct a.docx
Information is provided for you below that will help you construct a.docxInformation is provided for you below that will help you construct a.docx
Information is provided for you below that will help you construct a.docx
 
Individuals who are frequent voters share common characteristics, re.docx
Individuals who are frequent voters share common characteristics, re.docxIndividuals who are frequent voters share common characteristics, re.docx
Individuals who are frequent voters share common characteristics, re.docx
 
Infectious diseases come with extremely tough challenges to mitigate.docx
Infectious diseases come with extremely tough challenges to mitigate.docxInfectious diseases come with extremely tough challenges to mitigate.docx
Infectious diseases come with extremely tough challenges to mitigate.docx
 
Individual Reflection in which you describe the plan that you would .docx
Individual Reflection in which you describe the plan that you would .docxIndividual Reflection in which you describe the plan that you would .docx
Individual Reflection in which you describe the plan that you would .docx
 
Individual ProjectGroups in the WorkplaceSun, 10816.docx
Individual ProjectGroups in the WorkplaceSun, 10816.docxIndividual ProjectGroups in the WorkplaceSun, 10816.docx
Individual ProjectGroups in the WorkplaceSun, 10816.docx
 
Individual ProjectRecruitment Strategies and Tools Mon, 83.docx
Individual ProjectRecruitment Strategies and Tools Mon, 83.docxIndividual ProjectRecruitment Strategies and Tools Mon, 83.docx
Individual ProjectRecruitment Strategies and Tools Mon, 83.docx
 

Recently uploaded

clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 

In this assignment, you will implement a generic map interface in tw.docx

  • 1. In this assignment, you will implement a generic map interface in two ways: as a hash table with another map implementation from the activity (attached) If you prefer, you may implement and test maps of Strings (sample code in the right column below). You should use normal Java arrays for storage, not ArrayList or other classes from the Java Collections API. Your submission should be a zip file that includes the following files: IMap.java (below, no changes needed) IMapTest.java, HashMapTest.java, and OtherMapTest.java (below, no changes needed) use the first column for Generic version, second column for String version HashMap.java (your hash table implementation) (Here is the main task) OtherMap.java (your other implementation) (Here is the main task) Sample Code for Generics Sample Code for Strings (not Generic) interface IMap { boolean del (int key); // delete key & its value T get (int key); // get value for key boolean put (int key, T val); // put key,value in map boolean hasKey(int key); // is key in map? boolean hasVal(T val); // is val in map? void clear (); // remove all keys & values String dump (); // return String with contents int size (); // return # of pairs } interface IMap { boolean del (int key); // delete key & its value String get (int key); // get value for key
  • 2. boolean put (int key, String val); // put key,value in map boolean hasKey(int key); // is key in map? boolean hasVal(String val); // is val in map? void clear (); // remove all keys & values String dump (); // return String with contents int size (); // return # of pairs } import static org.junit.Assert.*; import org.junit.*; public abstract class IMapTest { protected IMap map; // each subclass should initialize map and then call super.before() public void before() { assertNotNull(this.map); this.map.put(1,"one"); } @After public void after() { this.map = null; } @Test public void constructor() { assertNotNull(this.map); } @Test public void clear() { assertEquals(1, this.map.size()); this.map.clear(); assertEquals(0, this.map.size()); } @Test public void del() { assertEquals(1, this.map.size()); assertFalse ( this.map.del(0));
  • 3. assertTrue ( this.map.del(1)); assertFalse ( this.map.del(1)); assertEquals(0, this.map.size()); } @Test public void get() { assertNull ( this.map.get(0)); assertEquals("one", this.map.get(1)); } @Test public void has() { assertTrue (this.map.hasKey(1)); assertTrue (this.map.hasVal("one")); assertFalse(this.map.hasKey(3)); assertFalse(this.map.hasVal("three")); assertTrue (this.map.put(3,"three")); assertTrue (this.map.hasKey(3)); assertTrue (this.map.hasVal("three")); } @Test public void put() { assertEquals(1, this.map.size()); assertFalse ( this.map.put(1,"one")); assertTrue ( this.map.put(3,"three")); assertFalse ( this.map.put(3,"three")); assertEquals(2, this.map.size()); } } import static org.junit.Assert.*; import org.junit.*; public abstract class IMapTest { protected IMap map; // each subclass should initialize map and then call super.before() public void before() {
  • 4. assertNotNull(this.map); this.map.put(1,"one"); } @After public void after() { this.map = null; } @Test public void constructor() { assertNotNull(this.map); } @Test public void clear() { assertEquals(1, this.map.size()); this.map.clear(); assertEquals(0, this.map.size()); } @Test public void del() { assertEquals(1, this.map.size()); assertFalse ( this.map.del(0)); assertTrue ( this.map.del(1)); assertFalse ( this.map.del(1)); assertEquals(0, this.map.size()); } @Test public void get() { assertNull ( this.map.get(0)); assertEquals("one", this.map.get(1)); } @Test public void has() { assertTrue (this.map.hasKey(1)); assertTrue (this.map.hasVal("one"));
  • 5. assertFalse(this.map.hasKey(3)); assertFalse(this.map.hasVal("three")); assertTrue (this.map.put(3,"three")); assertTrue (this.map.hasKey(3)); assertTrue (this.map.hasVal("three")); } @Test public void put() { assertEquals(1, this.map.size()); assertFalse ( this.map.put(1,"one")); assertTrue ( this.map.put(3,"three")); assertFalse ( this.map.put(3,"three")); assertEquals(2, this.map.size()); } } import static org.junit.Assert.*; import org.junit.*; public class HashMapTest extends IMapTest { @Before public void before() { this.map = new HashMap(10); super.before(); } } import static org.junit.Assert.*; import org.junit.*; public class HashMapTest extends IMapTest { @Before public void before() { this.map = new HashMap(10); super.before(); } }
  • 6. import static org.junit.Assert.*; import org.junit.*; public class OtherMapTest extends IMapTest { @Before public void before() { this.map = new OtherMap(10); super.before(); } } import static org.junit.Assert.*; import org.junit.*; public class OtherMapTest extends IMapTest { @Before public void before() { this.map = new OtherMap(10); super.before(); } }