Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Data Structures Homework, Spring 2015
- CSS 162A: Programming Methodology
- Instructor A. Retik
- Building Lists, Stacks and Queues with Arrays
- • Build three classes that conform to the following interfaces. Use arrays in creating your classes. Extend the provided sample driver to completely test your solutions.
- • The driver and document are posted in files/HW3 folder.
- ArrayList Interface
- void add(Object, int index)
- Object remove(int index)
- int size()
- String toString()
- boolean isEmpty()
- int indexOf(Object) //-1 if not found
- boolean equals(Object); //compare sizes and elements in the list
- Stack Interface (LIFO)
- void push(Object)
- Object pop()
- int size()
- String toString()
- boolean isEmpty()
- boolean equals(Object);
- Queue Interface (FIFO)
- void enqueue(Object)
- Object dequeue()
- int size()
- String toString()
- boolean isEmpty()
- boolean equals(Object);
- • You should practice building drivers and even more advanced testing harnesses yourself. The provided sample driver (ArrayBasedDataStructuresDriver.java) is merely a starting point that you can use to initially exercise your code.
- • Note that Stacks should be LIFO, Queues should be FIFO, and Lists can add and remove in arbitrary order.
- FAQ
- Q: Do these structures hold a fixed size set of items (i.e, static), or can they grow at runtime?
- A: Your software will be able to resize your array once capacity is reached, and will be tested beyond 100 elements.
- Q: What is FIFO? and LIFO?
- A: Good question.
- Q: How will you test this code?
- A: Using the same strategies and techniques shown to you in the first few HWs, but more complete.
- Q: Are comments (file headers, method headers, in-line comments) important?
- A: Comments are now worth almost 2 letter grades, so I'd include them.
- Q: I think there is a way to relate these classes via inheritance. Should I do this?
- A: We'll cover this later in the quarter; you should not use inheritance for this assignment.
- More to come in a lecture week 3.
- Deliverables: You should turn in four .java files, three are for your classes and the fourth is your test driver.
- About This Document
- Original assignment is created by Rob Nash. Minor edits by A.Retik, April 2015.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement