Category: pp - 63 day programming project

7: quiz web app

Quiz

Written in June 2008, this application shows multiple choice questions. See the code overleaf.

The input radio controls are NOT runat=server so “qst” + questionNr is used.

The questions are stored in a sqlite db. The answer is inline with the question, which uses a placeholder [options]. For ex:

We would study English if we [go | would go | will go | went] to England.

Read more »

6: morse code

Morse

Morse code is a simple way of sending textual information in the form of dots and dashes. It was how the telegraph operated, and dates both the telephone and the radio.

It can be read by humans without a decoding device. Its still used in aviation today.

This application simply converts a normal typed text into Morse, and plays it as well. Read more »

5: voting program

Intro

For counting votes (admin only), this simple program (written in 45 minutes) shows a set of buttons for each candidate and you can click on the button to increase his votes.

Candidates.txt is the input and also where the count is stored.
Once counting is over (or anytime), simply open the Count tab to see the results.

Count has 3 buttons. Clear to reset all counts to 0, Names to open the text file for editing, Reload when changes are made manually.

See code overleaf or browse or download.

Approach:

  • Create a Candidate Control which has a button to show his name and a label to display the number of votes. have it implement ICandidate for SoC
  • ICandidate has PersonName, Votes (int) and a Clear() method.
  • VoteForm loads from file and puts controls in a flow panel.
  • Candidate Control broadcasts a static event whenever a vote is made. this is listened in the Form and the text file is saved each time.

Read more »

4: sort xml in vsmdi files before comparing

Discuss

Visual Studio has an annoying way of shuffling up the content of a vsmdi file (the xml file used to store unit tests under lists)

When checking in, its impossible to be sure of the changes made when comparing with the old version.

This tool simply loads the xml, sorts the items inside a list node by name (using Linq.Xml) and saves the file. Read more »

3: endless list

Endless List

Suppose you need items pulled at random from a finite list of items.
The items should not repeat until all items in the list are returned.

See the code (overleaf)

Approach (for random):

  • Keep 2 lists viz: Used & Remaining.
  • first time / if items have changed, reset used and initialize remaining.
  • If nothing remains, move all used to remaining and clear used.
  • pick a random number from 0 to remaining.count
  • get corres item from remaining, remove it from there, add it to used and return it

Read more »

2: noughts n crosses

Intro

Tic Tac Toe is an old game. Players alternately get Xs or Os in their button. The first one to complete 3 in a row wins.

It requires a 3×3 button control array.

Form:

  • A button array of 9 buttons inside a flow layout panel.
  • a boolean as to which is the current player (text is filled in the buttons accordingly)
  • Each time a button is clicked, check if known solutions are matched / its a draw

Read more »

1: items by category

Explanation
This is a simple crossmatrix of items by category or categories by item.
Its developed as a simple standalone asp.net page with a backing static class (with xml serialization for persistence) 3 simple structs for item, category and ItemInCategory.

There are 5 tabs which show one after the other (on the same page)
Cats: Manage List of Categories / Add
Items: Manage List of Items / Add
Matrix: Lets you add items to categories.
Cat Viewer: Shows list of categories, letting you see the items belonging to them.
Item Viewer: Shows list of Items, and the categories in which they belong. Read more »