Assignment: Minibrowse Back and Forward Buttons

For this portion of the Minibrowse project, you will add Back and Forward buttons to your browser that work similarly to those in a real web browser. You should start with your Minibrowse code from the previous assignment (MinibrowseCore.java, Minibrowse.java), as this assignment doesn't depend on the success of the previous one. When you're done and you've submitted your work, feel free to integrate this assignment into your last one if you want to have your own personal version of Minibrowse with all the features.

If you haven't started working in a separate directory (folder) for each assignment by now, it is crucial that you start doing so. Make sure that you create a new empty directory to hold the code for this new assignment, then copy in the files that you need. If you have questions on how to do so, stop into CMC 306 and ask one of the friendly lab assistants for help.

Part 1: Stack201

Create a generic class called Stack201<E> that implements the four stack methods that we defined in class. You should implement your stack however you like: feel free to use an ArrayList, a LinkedList, or your own DoublyLinkedList class if you wish. You should not use any of the built in Stack-like classes from the Java Collections Framework (such as Stack or any of the Deque classes, etc.). This is so that you can gain the valuable experience of constructing a stack yourself. Once this assignment is complete and turned in, you will be free to use the standard classes on future homework assignments.

Part 2: Putting it together

Modify Minibrowse so that whenever a user enters a web page, its URL is pushed onto a stack associated with the Back button. Whenever a user clicks on the Back button, the current URL should be pushed onto a stack associated with the Forward button before a URL is popped off the Back button stack and displayed. Likewise, whenever a user clicks the Forward button, the same thing should happen in reverse. Make sure to handle the special case that if a user types in a URL into the address bar, the Forward button should be cleared (play around with a "real" browser and see how the Forward button behaves when you typed in a new web page).

The only mechanism you can use to store web pages is via pushing onto a stack. Don't "violate" the stack by inserting things into the middle. Specifically:

What to turn in, and when

Part 1: You should turn in a design document for the project. Designing the stack itself should be fairly straightforward, since you already have the interface; you don't need to indicate much here beyond what kind of implementation technique you want to use (arrays, linked lists, etc.) Most of your attention should be focused on how to integrate the stack into Minibrowse. One tricky part of this assignment is in how to handle the "current" web page. Where does it get stored? Does it go on top of one of the stacks, or in a separate location? When you go to another web page, where does the current web page go? When you hit the back button, where does the current web page go? Some students in the past have not thought carefully about this before coding, and tried to "patch" bugs afterwards. That tends to work poorly on this assignment. Thinking carefully about the whole scenario before you start should get your code working much more easily.

Make sure to include estimates of how long you think each part of the assignment will take you to do.

Part 2: Complete your Stack201.java. Stack201.java should have a main method that pushes and pops some Strings to demonstrate that it actually works. Think carefully about what kinds of cases you should be testing.

Part 3: Turn in the complete project, which includes Stack201.java, Minibrowse.java, and MinibrowseCore.java (unchanged).

Have fun, and good luck!