Computer Science 1xx – Assignment #N

DUE DATE: mmddyyyy  

Linked Lists and the 'Pong' Game


Learning Objectives:
(This is a list of the major topics that you, as students, will learn in this assignment:)

Grading Rubric: This document is available for you use - you should use it to  to help guide your work.  The rubric is a document which explains how your work will be evaluated, and is located here.



Part 1: Writing the program:

    For this assignment, you will be implementing a class, in order to make the 'Catch A Falling Toy' game fully functional.  You are given most of the XNA-specific code, so all you need to implement is the ListOfToys class, which is described below.

    The way the game works is that the player controls a 'paddle' at the bottom of the screen, which can move left or right (only - it can't move up or down).  There is a list of Toys, arranged across the top of the screen.  If you push the 'A' button, you will add a low-speed Tool to the list of Toys.  If you push the 'B' button, you will add a high-speed Animal to the list of Toys.  The game starts when you put a Toy (Tool or Animal) into the list, which the game will then promptly drop towards the bottom of the screen.  It's your job to move the box across the bottom of the screen and catch the falling Toy.  If you catch the toy, then you get points.  If the toy goes beyond the bottom of the screen, you don't get any points.  Once the toy is either caught (or leaves the bottom of the screen), then the next Toy in the list is dropped, for you to catch.

    The feature that's missing is the ListOfToys class, which allows the player to line up Toys to be used.  Once the current Toy has left the screen, the program will automatically get the 'oldest' Toy in line, and activate it, so that player can continuing playing, with a new Toy.  There are two types of Toys - High Speed Toys (Animals), and Low Speed Toys (Tools).  The player may line up many Toys, of both types, so that the game will deploy them as they become needed.  Your job is to implement the ListOfToys class, as described below.

            You should base your program's design off one of the Abstract Data Types that we've examined.  Note that in order to support the 'high priority' feature, you may need to deviate from a 'pure' implementation of the ADT – this is expected, and fine.  The ADT should be implemented using a linked list, so that you get experience implementing linked lists.

The interface to the ListOfToys class is defined below, so that you're clear on how the class needs to behave.  You are free to create other classes ('helper classes', or auxiliary classes) that you use to implement the ListOfToys class. 

After reading through the table below, it is recommended that you download the starter project for this assignment, and begin implementing the ListOfToys class.

ListOfToys  Data & Methods

Data Field Name



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




Nothing, by definition

Any initialization that you need to do



If you know about Exception Handling, and a substantial error occurs, you can throw an Exception.  You will also need to write the code that handles the exception, as well.


  1. ToySpeed s: This identifies the speed of the Toy
    (High or Low)

This method will take a ToySpeed, create a Toy object (passing the ToySpeed to the Toy's constructor), and then store that Toy object at the front of the line of Toys (making it the newest item in the line of Toys).

Once you've done everything that you need to in order to add a toy to the list, you need to call IterateAndCompute, passing it two parameters: an int, which is the total number of Toys (of either type) in the queue, and a reference to the node that contains a reference to the first toy in your list.  If there are no Toys in the list, you can safely pass the value null to this method.  This method will go through & adjust information on the ToyObjects, so that the toys will be drawn correctly.  The implementation of this method is included in the CListOfToysBase.dll, so that you can have access to the logic, but to prevent you from copying the logic for use in your own methods.




If you know about Exception Handling, and a substantial error occurs, you can throw an Exception.  You will also need to write the code that handles the exception, as well.

Parameters: None

This method will silently remove the 'oldest' Toy, assuming that there is one.  To be clear: each call to this method removes exactly one Toy from the ListOfToys, and returns that object.  If there are no Toy objects in the ListOfToys, then this method will return the value null.

High speed Toys are removed before Low speed Toys.  For High speed Toys, those High speed Toys that were added first will be removed first ; once any and all High speed Toys have been removed, then the Low speed Toys will be removed - the Low speed Toys that were added first will be removed first. 

isEmpty bool

Parameters: None


Returns true if there are no Toy objects currently being tracked stored in the line.

Returns false is there is at least one Toy object in the ListOfToys

CurrentToyCount void

Parameters: None

This method needs to go through all the Toys that are in the ListOfToys, and count and print the number of high speed animals and low speed tools currently in the line.You can do this using the EchoToBottomStatus> command - you can pass it a string that contains the text that you want to have appear in the bottom status bar.

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 CurrentToyCount()) should run in O(1) time and space.


How To Play The Game:


How To Play The Game:
Game/Program Controls: XBox
When running the game/program, you can control it using the following Gamepad controls:

§     Left thumbstick to move cursor (red dot)

§     Button-A to add a Tool (a low-speed Toy) to the list

§     Button-B to add an Animal (a high-speed Toy) to the list

Game/Program Controls: PC
When running the game/program, you can control it using the following keyboard controls:

Here is the keyboard to controller mapping.


Group Work, Commenting:


            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 142”), 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:


·        A single electronic folder (a directory).  This folder should contain:

o       The source code for the program – all the .CS files in your project.
I would prefer that you include the project files – stuff ending in .SLN and .VCPROJ, so I can build your project more easily.  If you can save these files (the .SLN / . VCPROJ) into a file format that can be opened by VS.Net 2003, that would be great.

o       You have to name the folder with your last name, then first name, then the assignment number (both the major version – 2, and the minor (revision) number – 0).  Example: "Panitz, Mike, A2.0"


·        You should not include the Debug directory, or anything from it.  I will dock you a couple points if you do.  Also, you don't need to include your .NCB file, if it's present.


How to electronically submit your homework:


There's a link on the homework page to the document that guides you through handing in your work, using the SourceGear Vault program.


This document and the related materials are developed with support from Microsoft Research Computer Gaming Initiative under the Computer Gaming Curriculum in Computer Science RFP, Award Number 15871.