SlideShare a Scribd company logo
1 of 6
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.pdfarjuntelecom26
 
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.pdffathimafancyjeweller
 
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.pdfaromanets
 
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 prakasaDeprilana 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.pdfmarketing413921
 
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.pdfmohdjakirfb
 
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.pdfkamdinrossihoungma74
 
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.docxajoy21
 
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.docxmercysuttle
 
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 .pdfsiennatimbok52331
 
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.pdfanushkaent7
 
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 programmingHenri Tremblay
 
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.pdfARCHANASTOREKOTA
 
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.docxandreecapon
 

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

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

Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Celine George
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
The Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxThe Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxNehaChandwani11
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxMohamed Rizk Khodair
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Denish Jangid
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIagpharmacy11
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/siemaillard
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 

Recently uploaded (20)

“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.
 
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
The Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxThe Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptx
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 

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(); } }