Computer Science 1xx – Assignment #N

DUE DATE: mmddyyyy  

The Chameleon Game: Modulus, and other operators

 

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

  1. Operators
    In this assignment, you will need to write a program that uses several C#operators, including the modulus operator, and the integer division operator (including strategies for forcing real division instead of integer division, such as type casting) 
     
  2. Conditional execution control
    In this assignment, you will need to write code that utilizes if statements, if/else statements, and switch statements.
     
  3. Elementary Solution Synthesis
    In this assignment, you will be provided with a starter project, and you will need to add your code to it, in order to successfully complete the assignment.  The parts that you need to modify are clearly marked (using comments) so that you shouldn't need to understand (or be distracted by) any of the other code, although you are welcome to look through the rest of the program, if you'd like.

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.

 

Please note that this assignment consists of two parts - parts #1 is mostly coding, and part #2 (below) is entirely written.  Make sure to do both parts!

 

Part 1: Writing the program: Modulus Operator, Conditional Statements

For this program, you'll be responsible for implementing part of an existing game.  Most of the game will be provided to you, and you will have to provide a method will will handle two aspects of the game:  initializing the color-coding of the game board, as well as the color-coding of the player's avatar (it will actually be a picture of a chameleon, but hey, avatar sounds better :)  ).

When the game starts, the player should see the following screen that looks something like the following: vertical bars of color where the color repeats every 7 bars and a circle.  Note that in the game, the player will control the circle - it can be moved left/right with the left/right triggers.

The game plays as follows: As the player moves the chameleon (or avatar) horizontally, the circle will enter into vertical bars of different colors.  The circle surrounding the chameleon should match the color of the vertical bar that's behind the chameleon.  In order to keep things simple, we're going to have the color of the circle match the vertical bar that the center of the circle inside of. In the above picture, the center of the chameleon's circle is in a blue-green/teal vertical bar, so the entire circle is colored blue-green/teal. 

It is your responsibility, as a student, to write up the game-logic that is responsible choosing the colors of the the color bars, and for choosing the color of the player's circle around the chameleon (*ahem*-avatar). 

There are extensive comments in the source code for the students' assignment template (the starter project) so that you don't have to examine the entire program (although you're welcome to do so, if you want to!).  The actual code that you have to fill in is clear specified in the source code (it's between the note that says "STUDENTS: YOU NEED TO WRITE YOUR CODE BELOW:", and "STUDENTS: YOU NEED TO WRITE YOUR CODE ABOVE:").  Please note that you don't need to modify anything else in the program, and that you may be penalized if you do modify other parts of the program in order to accomplish the objectives of this assignment.

As a final note, there are two major objectives for this assignment

  1. For the student to learn more about operators (including the modulus operator, and the 'integer division' aspect of the division operator)
    (This section is clearly identified in the code by the phrase "
    THIS IS THE 'OPERATOR' SECTION OF THE HOMEWORK")

  2. and to make sure that each student is comfortable using conditional statements, specifically:

    1. A series of basic if statements

    2. A series of if...else statements

    3. A single switch statement.


    In order to receive full credit for this assignment, you need to implement all three versions of this solution, which is explained in greater detail in comments, in the source code for the assignment (in the file BackgroundStrip.cs - from lines 34 through 117).
    (This section where you have to write your code is clearly identified in the code by the phrase "
    THIS IS THE 'CONDITIONAL STATEMENTS' SECTION OF THE HOMEWORK", on or near line 86)

Remember that your program will not run unless you have a solution to both objectives #1 and #2 (but you can use any one of #2A, #2B, or #2C)!

Part 2: Demonstrating Critical Thinking

            You need to write up your answers to the following questions, and store those answers in any format the instructor can read.  A Microsoft Word document is fine, text is fine, HTML is fine, PDF is fine.  For anything else, ask first.  Clearly, the program you're writing for this assignment may be helpful in answering these questions, but if you do them 'by hand' (or rather, 'by mind'), that's great, too. 

            For all of the following questions, assume that you're working with the equation

A % B = C.

            For each question, clearly and concisely state your answer, as well as an intuitive, easy-to-understand explanation explaining why you always get the answer that you do.  Imagine that you're trying to explain this to someone who neither programs, nor does much math.

 

1.      When A is less than B, what will C be?

 

2.      When A is == B, what will C be?

 

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/Right trigger moves circle

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.