CS1                                                                                    
Object References, and Arrays

(Ropes & Ladders (XNA) ; PeriodicTable  (Console) )

 
Key Topics That Students Will Learn In This Assignment:
  1. One-Dimension Arrays of Object References
    (Primarily traversing an array of object references, including allocating new objects,  modifying existing objects, and dealing with null references.  Optionally, one could extend this assignment to also require the students to pass arrays to/from methods, but this is currently not required.)
     
  2. Basic object oriented programming
    (Multiple, interacting classes will need to be implemented.  The goal here is to learn how to implement functionality that is spread across multiple classes, rather than putting everything into a single class & method.)
Pre-requisite Knowledge That Students Must Know, Prior To Starting This Assignment:

(What students must know before completing this assignment)

  • Flow Control: conditional selection (if statements)
  • Flow Control: iteration (loops)
  • Simple/Primitive Variables: int, double (etc)
  • Encapsulation
  • Arrays: 1-dimensional arrays of references to objects
  • OOP: Basic OOP, including having to define new classes or methods.
  • Console version: Basic Console Input/Output
  • XNA version: Random Number Generation
Summary The primary goal for these assignments is to provide students with the opportunity to practice some basic object oriented programming (by defining a simple class, instances of which will then be stored in the array). 

For the Console assignment, the students will complete a program that allows the user to display, edit, and add elements to a Periodic Table Of Elements (a la chemistry).  In order to do this, the students will have to fill in an Element class, and then create at least 10 instances of the class (each instance represents a single Element, such as Carbon, or Hydrogen).  They will then have to complete the implementation of a PeriodicTable class, which manages access to the array of Elements, including dealing with empty array slots (i.e., dealing with null references in the array).

For the XNA assignment, the students will complete a program that allows the user to play a variation of the 'Snakes And Ladders' board game.  Each turn, the player is allowed to choose to move forwards by a random distance.  If the player lands on a space that contains a piece of gold, the gold will be removed from the board, and added to the player's total.  If the player lands on a snake, then will go down/backwards to a lower space.  If the player lands on a ladder, then will go up/forwards to a higher space. In addition to choosing to move randomly, the player may decide to create a new snake or ladder - the destination of which is randomly chosen.
In terms of programming, the students will have to fill in the GameCell class, and they will then have to complete the implementation of a GameBoard class, which manages access to the array of GameCells, including dealing with empty array slots (i.e., dealing with null references in the array).

  Instructor F.A.Q.
Pre-Test Post-Test
Lecture Hours Prior To Assignment Due Date: 15
ACM Classification (Topics Covered):

(What the students will learn, and demonstrate, by doing this assignment)

 

From:
 

Computing Curricula 2001

Computer Science

Final Report
(December 15, 2001)


written by
 

The Joint Task Force on Computing Curricula
IEEE Computer Society
Association for Computing Machinery

 

PF1. Fundamental programming constructs

  • Basic syntax and semantics of a higher-level language

  • Variables, types, expressions, and assignment

  • Simple I/O (Console Version)

  • Conditional and iterative control structures

  • Functions and parameter passing

  • Structured decomposition

PF3. Fundamental data structures

  • Primitive types

  • Arrays

  • Records

  • Pointers and references

PL6. Object-oriented programming

  • Encapsulation and information-hiding

  • Separation of behavior and implementation

  • Classes and subclasses

Technical Requirements:

(What the students will learn, and demonstrate, by doing this assignment)

 

From:
 

Computing Curricula 2001

Computer Science

Final Report
(December 15, 2001)


written by
 

The Joint Task Force on Computing Curricula
IEEE Computer Society
Association for Computing Machinery

 

It is hoped that providing this information may help instructors with the accreditation process, as calling this information out will help clarify how this assignment (and from here, the overall course) meets the learning outcomes for the overall program/department, and institution.


PF1. Fundamental programming constructs

PF1.1 - Analyze and explain the behavior of simple programs involving the fundamental programming constructs covered by this unit.

(The students are given code, and required to demonstrate that they understand the program by modifying the program)

 

PF1.2 - Modify and expand short programs that use standard conditional and iterative control structures and functions.

(The students are given code, and required to demonstrate that they understand the program by modifying the program)

 

PF1.3 - Design, implement, test, and debug a program that uses each of the following fundamental programming constructs: basic computation, simple I/O, standard conditional and iterative structures, and the definition of functions.

(The students are given code, and required to demonstrate that they understand the program by modifying the program.  Their modifications must include those topics listed above.)

 

PF1.4 - Choose appropriate conditional and iteration constructs for a given programming task.

(The students will need to do this in this assignment, as they check for out-of-bounds errors, and iterate through the array.)

 

PF1.5 - Apply the techniques of structured (functional) decomposition to break a program into smaller pieces.

(While note a primary topic for this assignment, the students will be creating a program out of a collection of smaller methods.)

 

PF3. Fundamental data structures

PF3.6 - Write programs that use each of the following data structures: arrays, records, strings, linked lists, stacks, queues, and hash tables.

(This assignment makes extensive use of arrays, as well as classes (records) )

 

PL6. Object-oriented programming

PL6.2 - Design, implement, test, and debug simple programs in an object-oriented programming language.

(C# is an object-oriented programming language, and this assignment requires students to solve the given problem using an object-oriented approach )

PL6.3 - Describe how the class mechanism supports encapsulation and information hiding.

(The students are required to properly encapsulate their code, but they must decide how to do this, thus ensuring that they are demonstrating a clear understanding of what this means.)
 


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.