Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. Data Structures Homework, Spring 2015
  2. CSS 162A: Programming Methodology
  3. Instructor A. Retik
  4. Building Lists, Stacks and Queues with Arrays
  5.  
  6. • 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.
  7. • The driver and document are posted in files/HW3 folder.
  8.  
  9.  
  10. ArrayList Interface
  11. void add(Object, int index)
  12. Object remove(int index)
  13. int size()
  14. String toString()
  15. boolean isEmpty()
  16. int indexOf(Object) //-1 if not found
  17. boolean equals(Object); //compare sizes and elements in the list
  18.  
  19. Stack Interface (LIFO)
  20. void push(Object)
  21. Object pop()
  22. int size()
  23. String toString()
  24. boolean isEmpty()
  25. boolean equals(Object);
  26.  
  27. Queue Interface (FIFO)
  28. void enqueue(Object)
  29. Object dequeue()
  30. int size()
  31. String toString()
  32. boolean isEmpty()
  33. boolean equals(Object);
  34.  
  35.  
  36. • 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.
  37.  
  38. • Note that Stacks should be LIFO, Queues should be FIFO, and Lists can add and remove in arbitrary order.
  39.  
  40. FAQ
  41.  
  42. Q: Do these structures hold a fixed size set of items (i.e, static), or can they grow at runtime?
  43. A: Your software will be able to resize your array once capacity is reached, and will be tested beyond 100 elements.
  44.  
  45. Q: What is FIFO? and LIFO?
  46. A: Good question.
  47.  
  48. Q: How will you test this code?
  49. A: Using the same strategies and techniques shown to you in the first few HWs, but more complete.
  50.  
  51. Q: Are comments (file headers, method headers, in-line comments) important?
  52. A: Comments are now worth almost 2 letter grades, so I'd include them.
  53.  
  54. Q: I think there is a way to relate these classes via inheritance. Should I do this?
  55. A: We'll cover this later in the quarter; you should not use inheritance for this assignment.
  56.  
  57. More to come in a lecture week 3.
  58.  
  59. Deliverables: You should turn in four .java files, three are for your classes and the fourth is your test driver.
  60.  
  61.  
  62. About This Document
  63. Original assignment is created by Rob Nash. Minor edits by A.Retik, April 2015.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement