Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. Lab 07: DoubleLinkedSeq
  2. The Sequence ADT Using Linked Lists
  3.  
  4. 1 Introduction
  5.  
  6. A sequence is an ordered list of elements that grows as necessary to hold everything you try to put in it. For this assignment you will develop a sequence abstract data type (ADT) using linked lists. Recall that an ADT defines a type and a set of operations on that type. It is abstract in the sense that users of the type don’t need to know about the details of how the data is stored or how the operations work – they just work.
  7.  
  8. A sequence has a notion of a “current element." Several of the operations on a sequence are in terms of the current element.
  9.  
  10.  
  11. 2 Details
  12.  
  13. For this assignment, you will implement the DoubleLinkedSeq class described in Section 4.5 of your textbook (pages 235-238). See the API documentation in the text for a description of the class and the methods that it must provide. Additionally, you must provide (1) a toString() method that returns a String representation of the DoubleLinkedSeq and (2) an equals() method that determines if two DoubleLinkedSeq are equal.
  14.  
  15. 1. The toString() method must return a string in the following form. If the sequence is empty, the method should return “<>”. If the sequence has one item, say 1.1, and that item is not the current item, the method should return “<1.1>”. If the sequence has more than one item, they should be separated by commas and a space, for example: “<1.1, 2.2, 3.3>”. If there exists a current item, that item should be surrounded by square braces. For example, if the second item is the current item, the method should return: “<1.1, [2.2], 3.3>”.
  16. 2. the equals() method should return true if the two sequences contain the same number of elements, if the corresponding entries in the sequence are the same, and if they have the same current element.
  17.  
  18. Activity Steps
  19.  
  20. 1. Log on to the student machine. Change to your 2440 directory. Make a new Lab07 directory in your CS 2440 directory. Change to this directory. From within this directory, copy the "starter code" from /u/classes/2440/Fall2016/Sequence2/src. Make sure that you do a recursive copy!
  21. 2. You should have copied four files: DoubleLinkedSeq.java (src/skeleton), DoubleLinkedSeqTest.java (src/tests), TestDoubleLinkedSeq.java (src/util), and DoubleNode.java (src/util). You will be implementing the DoubleLinkedSeq described in the textbook. If you use the DoubleLinkedSeq.java that you copied, you will have the ADT from the book, and I added stubs for all the methods. To get past the compiler, all methods that return a value have some arbitrary dummy value returned.
  22. 3. Rename the skeleton directory to ‘solution’ and open src/solution/DoubleLinkedSeq.java
  23.  
  24. First edit the first line so that it reads “package solution;” instead of “package skeleton;”
  25. 4. If everything is setup correctly, it should compile with the following (from within the Lab07 directory):
  26.  
  27. $ javac -cp .:src:/usr/share/java/junit-4.10.jar src/*/*.java
  28. 5. Add the fields to your class. You must use a linked list. I suggest using the five fields suggested by the book - manyNodes, head, tail, precursor, and cursor.
  29. 6. One by one implement the methods your class. As you implement your methods, test your code. There is a class TestDoubleLinkedSeq.java that has a menu that allows you to test a single method, and it displays the sequence after each test is done. However, their display method calls your start(), advance(), getCurrent(), and isCurrent() methods, so you will need to write those before you can make much sense out of that test program.You will also need to have your clone() method written to prevent errors in TestDoubleLinkedSeq.java and DoubleLinkedSeqTest.java.
  30. 7. Finally, when you have all the methods written and tested, compile and run the JUnit DoubleLinkedSeqTest to find out approximately what your lab grade will be:
  31. Note: all of the following commands assume that your current working directory is Lab07.
  32.  
  33. To compile your java files into .class files:
  34.  
  35. $ javac -cp .:src:/usr/share/java/junit-4.10.jar src/*/*.java
  36. To run the JUnit tests:
  37.  
  38. $ java -cp .:src:/usr/share/java/junit-4.10.jar org.junit.runner.JUnitCore tests.DoubleLinkedSeqTest
  39. It probably will be hard to read all the output from the test. You can redirect the output to a file, and look at the file:
  40.  
  41. $ java -cp .:src:/usr/share/java/junit-4.10.jar org.junit.runner.JUnitCore tests.DoubleLinkedSeqTest > output
  42. To run TestDoubleLinkedSeq.java:
  43.  
  44. $ java -cp .:src:/usr/share/java/TestDoubleLinkedSeq.java util.TestDoubleLinkedSeq
  45. To make sure your project passes checkstyle:
  46.  
  47. 1. Make sure checkstyle-all-4.4.jar and cs_appstate.xml are in your project directory:
  48. $ wget http://cs.appstate.edu/~rmp/checkstyle-all-4.4.jar
  49. $ wget http://www.appstate.edu/~waterscg/cs_appstate.xml
  50. 2. Run checkstyle:
  51.  
  52. $ java -jar checkstyle-all-4.4.jar -c cs_appstate.xml src/solution/*.java
  53.  
  54. 3. If your code passes all checks you should see:
  55. Starting audit…
  56. Audit done.
  57. To submit your project to Web-CAT use the command line interface:
  58.  
  59. 1. Make sure webcat-submitter-1.0.5.jar and webcatSubmit are in your project directory:
  60. $ wget http://cs.appstate.edu/~rmp/webcat-submitter-1.0.5.jar
  61. $ wget http://cs.appstate.edu/~rmp/webcatSubmit
  62. 2. Make sure that webcatSubmit is executable:
  63. $ chmod 0755 webcatSubmit
  64. 3. Run the submitter (please notice the period, it means submit the current working directory):
  65. $ ./webcatSubmit .
  66. 4. Enter the number to the left of the name of the lab.
  67. 5. Enter your user name and password.
  68. 6. Login to Web-CAT to view your results.
  69. 7. For more information, see Submitting an Assignment to Web-CAT via the command line.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement