DUE DATE: < Listed In Course Schedule >
You are not allowed to work in groups this assignment. For this assignment, you should start, finish, and do all the work on your own. If you have questions, please contact the instructor.
|
Learning Objectives:
(This is a list of the major topics that you, as
students, will learn in this
assignment:)
Imagine that you're writing an application to manage a browser's history. Because we want to keep things (relatively) simple for this homework assignment we're only going to track the name of each page (specifically, we're not going to track the URL, or the contents of the page, etc). Essentially, the way the program works is that you visit a page and then the program adds that page to the 'history' that it's tracking. As you add more pages it'll keep adding these new pages to your history. You can then 'back up' in the history, much like you can push the 'Back button' in a real web browser. When you back up in the history the program moves the most recently visited page from your history into a list of 'future' pages, so that if you choose to then go forwards in your history you can revisit those pages. Here's an example transcript of one run of the program;
Example Transcript (user input is underlined, bold, and highlighted) |
Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:1 History: Previously visited pages: Pages in your 'future': Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:4 What page are you visiting? Page 1 (Google) History: Previously visited pages: Page 1 (Google) Pages in your 'future': Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:4 What page are you visiting? Page 2 (Hacker News) History: Previously visited pages: Page 2 (Hacker News) Page 1 (Google) Pages in your 'future': Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:4 What page are you visiting? Page 3 (Ars Technica) History: Previously visited pages: Page 3 (Ars Technica) Page 2 (Hacker News) Page 1 (Google) Pages in your 'future': Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:4 What page are you visiting? XKCD History: Previously visited pages: XKCD Page 3 (Ars Technica) Page 2 (Hacker News) Page 1 (Google) Pages in your 'future': Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:4 What page are you visiting? explainxkcd.com History: Previously visited pages: explainxkcd.com XKCD Page 3 (Ars Technica) Page 2 (Hacker News) Page 1 (Google) Pages in your 'future': Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:2 Moving backwards in your (browser) history: History: Previously visited pages: XKCD Page 3 (Ars Technica) Page 2 (Hacker News) Page 1 (Google) Pages in your 'future': explainxkcd.com Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:2 Moving backwards in your (browser) history: History: Previously visited pages: Page 3 (Ars Technica) Page 2 (Hacker News) Page 1 (Google) Pages in your 'future': XKCD explainxkcd.com Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:2 Moving backwards in your (browser) history: History: Previously visited pages: Page 2 (Hacker News) Page 1 (Google) Pages in your 'future': Page 3 (Ars Technica) XKCD explainxkcd.com Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:2 Moving backwards in your (browser) history: History: Previously visited pages: Page 1 (Google) Pages in your 'future': Page 2 (Hacker News) Page 3 (Ars Technica) XKCD explainxkcd.com Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:3 Moving backwards in your (browser) history: History: Previously visited pages: Page 2 (Hacker News) Page 1 (Google) Pages in your 'future': Page 3 (Ars Technica) XKCD explainxkcd.com Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:3 Moving backwards in your (browser) history: History: Previously visited pages: Page 3 (Ars Technica) Page 2 (Hacker News) Page 1 (Google) Pages in your 'future': XKCD explainxkcd.com Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:4 What page are you visiting? New Page 4 History: Previously visited pages: New Page 4 Page 3 (Ars Technica) Page 2 (Hacker News) Page 1 (Google) Pages in your 'future': Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:1 History: Previously visited pages: New Page 4 Page 3 (Ars Technica) Page 2 (Hacker News) Page 1 (Google) Pages in your 'future': Your options are: 1) View your history 2) Move 1 page backwards in your 'browser history' 3) Move 1 page forwards in your 'browser history' 4) Visit a new page 5) Quit Type in your choice here:5 |
As you examine the above transcript you should notice that if you 'back up' in the history and then visit a new page the program will remove all the pages your 'future'. Also note that backing up past the first entry is not possible, nor is it possible to move forwards when there's no items in the 'future'.
You should base your program's design off one of the Abstract Data Types that we've examined. The ADT should be implemented using a linked list, so that you get experience implementing linked lists. You need to write this code yourself, from scratch - it is NOT ok to use any LinkedList class made by anyone else (including the one built into .Net/C#). Also, do NOT use a doubly-linked list for this assignment. (If you stick with what we covered in class you will do fine, regardless of whether you know what a ‘doubly linked list’ is or not).
Starter Project: You will be provided with a starter project that will provide you with a console-based user interface that will use the code that will use the BrowserHistory class that you implement in order to provide the functionality described in the previous paragraph.
The interface to the BrowserHistory class is defined below, so that you're clear on how the BrowserHistory class needs to behave. You are free to create other classes ('helper classes', or auxiliary classes) that you use to implement the BrowserHistory class.
BrowserHistory Data & Methods |
|||
Data Field Name |
Type |
Description: |
|
You're free to add any |
data fields that you need to, in |
order to accomplish the objectives set forth in this assignment |
|
Note: all data fields should be marked private (if you need to expose them, use Properties, or accessor/mutator methods) |
|||
Method Name |
Returns |
Description/Parameters: |
|
<constructor> |
Nothing, by definition |
Any initialization that you need to do | |
VisitPage | void |
Parameters:
This method will take the page's name, and immediately add that page to the 'previously visited' part of the browser's history. |
|
MoveBackwards
|
void |
Parameters: None This method does the opposite of the |
|
MoveForwards
|
void |
Parameters: None This method does the opposite of the |
|
PrintAll | void |
Parameters: None If there are any pages in the history this method will print them all. Note that you must print out all the pages in the 'previous' history, then print out all the pages in the 'future history', as shown in the transcript above. |
|
Note:
all methods should be marked public Note: All methods should run in a minimum amount of time, and with a minimum amount of space (memory) consumed. Using Big 'Oh' notation, all methods (except PrintAll) should run in O(1) time and space. |
In the weekly exercises we looked at using some of the basic data structures that are built into the standard C# library. You do not need to use any of these classes to solve this project, nor are you allowed to. To be clear: You need to write all the code for this yourself, using just 'basic' C#.
You are not allowed to work in groups for this assignment. You should start, finish, and do all the work on your own. If you have questions, please contact the instructor.
Additionally, you should aggressively comment your code, paying particular attention to areas that are difficult to understand. If you found something to be tricky when you wrote it, make sure to comment it so that the next person (the instructor, who's grading you) understands what your code is doing. It is not necessary to comment every single line.
The purpose of new requirement is to both help you understand, and have you demonstrate, a thorough understanding of exactly how your program works.
Every file that you turn in should have:
At the top of each file that
you normally edit, you should put your name (first and last), the name of this
class (“BIT 143”), and the year and quarter, and the assignment number,
including the revision number, which starts at 0 (“A2.0”). If you’re handing
this in again for a regrade, make sure to increase the minor version number by
one (from “A2.0”, to “A2.1").
You normally edit the C# source code files (.CS files), and any Word documents
that you're handing in (if any).
You do not normally edit the .SLN or .CSPROJ files, and so you should not try to
put this identifying information in those files.
In general, you should make sure to do the following before handing in your project:
All variables used should have meaningful names.
The code should be formatted consistently, and in an easy to read format.
What to turn in:
o
The
C# source code for the entire program.
Please include all the .CS files,
whether you've changed them or not, just on the off chance you forgot that you
changed them.
How to electronically submit your homework:
This was covered in a separate document in this website..