How to use WebSubmit

Project 1: Building Rome in a Day

Objective

 

Make sure that students understand the basics of C# from ITFN1303 such as function calls, parameter passing, conditionals, iteration, input and output streams, the preprocessor, and the Microsoft Visual .NET C# IDE.

 

This program should be relatively easy for you if you know the prerequisite information from Intro to C#.  If this project is difficult for you, make sure you’re up to speed on the ITFN1303 topics.

Estimated Time to Completion: < 4 hours

Task

 

Write a program in Microsoft Visual C# that prompts the user for a non-negative integer over and over, each time printing out the Roman numeral equivalent, until the user enters the value zero (0). 

 

Some important Roman numerals you might be interested in (see the pattern?):

1          I

2          II

3          III

            4          IV

5                     V

9                     IX

10                 X

40         XL

49                 XLIX

50                 L

90                 XC

99                 XCIX

100              C

400              CD

500              D

999              CMXCIX

1000          M

3999     MMMCMXCIX

You must do the following:

 

 

50%      Write the main algorithm that loops, asking the user for an integer between 0 and 3999 until the user enters zero (0).  You must do range checking, so that if the user enters an invalid number (a negative or >= 4000), an error message is printed (but the loop continues).

 

75%      Write a function that takes in an integer (1-3999) via a by-value parameter and prints out the Roman numeral equivalent.  Return 0 upon successful completion of the function.

 

100%    Call the function you wrote for part 2 (above) from the main algorithm for each valid integer (1-3999) entered by the user.

Deliverable

 

.cs file which compiles and works as defined above.

 

Any file that doesn’t compile or terminates “ugly” will receive no credit.

Project 2: Coloring

Objective

To explore the concept of recursion and collections

Estimated Time to Completion: 10-15 hours

Task

Solve the coloring problem: given an n x n array, and quarters which can be one of 4 colors (i.e. red, green, blue or yellow), how many ways can you place the quarters in the array such that no two adjacent (neighboring) quarters are the same color?

This problem is solved by going through all possible combinations of boards; what you need is a board class that has the ability to clone itself, and has the ability to verify itself (to ensure that two colors aren't the same), along with a couple of other useful functions:

class Board {
    // attributes, constructor, etc...

    // Here's the copy function
    Board copyBoard ( ) {
        // return a new Board that has a copy of all the attributes of this board!
    }

    // Here's the verify function
    bool verifyBoard (int i, int j) {
        // return either a true or false as to whether or not the quarter at  location i, j is valid
    }

    // Here's a print function
    void printBoard ( ) {
        // have two nested loops that print out the values of each slot
    }

    // Determine if the board is full
    bool isFull ( ) {
        // have two nested loops that print out the values of each slot
    }

}

Then, you can create a function in Board called calculate that takes in a board (and current coordinates); if the board is verified and not full, tries the next slot with all 4 different colors.  If the board is full and verified, then you can increment the number of 'wins' by one, and print out that board.  If the board isn't verified, the function returns.

Be careful on the verifyBoard function.  It needs to check only the quarter to the left and above it.  This has a special case for either i or j equaling 0.

Deliverable

One .cs file.

 

Project 2.5: N-Queens Problem (Makeup for homework 2)

Objective

Finally understand this whole recursion/board generation thing...

Estimated Time to Completion: 10 hours

Task

For this assignment, you are asked to solve the n-queens problem, which states that, given an n x n chess board, how can you position n queens such that no queen can attack another.  Queens are able to attack along the horizontal row, the vertical column, and along diagonals. 

Your program should read in a number from the user to determine the board size. The output can be done in ASCII, but should show that positions the queens - satisfying the conditions above.

The algorithm itself is for all positions in a column, place a queen, then recursively call to place the next piece in the next column.  At the placement of each piece, you need to verify that it is not able to attack another piece.

Deliverable

All needed .cs file(s).

 

 

Project 3: Simulation a Sausage Stack, Yuck! (SaSSY)

Objective

Work with a Stack data structure and explore the idea of FILO servicing

Estimated Time to Completion: 10 hours

Task

Imagine that you're visiting a local all-you-can-eat breakfast bar; among the many items on the bar is a pan of sausages.  Your task is to simulate the sausage pan.  Note that when new sausages are added to the pan, they're always added to the top (the worker just dumps new sausages on top of the old sausages); also note that whenever someone takes a sausage to eat, they pick the top-most sausage.  Thus we've got a stack (first-in, last-out) and the bottom-most sausage is always the oldest.  For sake of simplicity, imagine that the pan only allows you to select a "top" sausage (i.e. you can't pick among many).

Your task is to implement a stack collection (or even better use the STL stack or vector class to save yourself some implementation time).  Your program should allow the user to add a sausage, remove a sausage, and print the status of the stack.  The stack should store the time in which the sausage was added, and when a sausage is removed, the program should display how long the sausage "lived" in the pan (i.e. the difference from now to when it was added to the pan).

Important items to consider:

My sample solution (C++).

Deliverable

All needed .cs file(s).

 

Project 4: Implementing a Binary Search Tree Class

Objective

 

Work with dynamic data structures like trees and linked-lists.

Estimated Time to Completion:  10-15 hours

Task

 

Create a "binary search tree" class that contains the following member functions:

 

Add your class(es) into the provided "menu system" to demonstrate that it functions properly.

 

HINTS

Deliverable

All needed .cs file(s).

 

Project 5: Multithreaded Network Program

Objective

 

Explore multithreaded and networked based programming.

Estimated Time to Completion:  10 hours

Task

 

Write a program in C# (or Java for the Java students) that asks a user for an IP (or machine name) and "port scans" the specified machine.  Rather than waiting quite a while for each port to be scanned before scanning the next port, your program must generate a new thread for each port; the thread's responsibility is to then scan a port and print out a message if the port is open.  Your program should scan the first 2048 ports on the machine, and each port is to be scanned by a unique thread.  Your main program does not need to block (i.e. "join") on the threads.

 

NOTE - we STRONGLY recommend you only test your program on your local machine (using "localhost" as the machine name) since it's considered bad practice to port scan other machines.

 

Here is my sample running program (requires the .NET framework).

 

HINT - remember to "close" the connection/socket once you've tried it.

 

HINT 2 - remember that it is possible to run out of threads, so catch the "OutOfMemoryException" and try to create the thread again after "Sleep(0)".

Deliverable

All project files - ZIPPED.

 

Project 6: Working with Arraylists

Objective

 

Explore the arraylist and C#  programming.

Estimated Time to Completion:  10 hours

Task

 

Write a class that simulates a deck of cards.

 

Write a class called Card that has the following attributes and methods

 

Write a class called Deck that has the following attributes and methods

Create a simple GUI that demonstrates the correct working of your classes above.  Your GUI must:

 

Note – you may use any collection class or algorithm as you see fit.

 

Things to consider

Deliverable

All project files - ZIPPED.

 

Project 7: C# Blackjack

Objective

 

To explore C# programming and visual controls

Estimated Time to Completion:  15-25 hours

Task

Create a visual interface and implement the program to play Blackjack in C#.  Details below:

Things to consider:

Deliverable

 

You will demo your finished project in class on 12/4.