Project 1: Building Rome in a Day
Objective
Make sure that students understand the
basics of C/C++ from ITFN1303 such as function calls, parameter
passing, conditionals, iteration, cin/cout streams, the
preprocessor, and the Microsoft Visual C++ IDE.
This program should be relatively easy for
you if you know the prerequisite information from Intro to C/C++.
If this project is difficult for you, make sure youre up to
speed on the ITFN1303 topics.
Estimated Time to Completion: < 2 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
CPP file which compiles and works as
defined above.
Any file that doesnt compile or
terminates ugly will receive no credit.
Project 2: If I Could Buy the World a Coke
Objective
Define a class with public and private
sections, constructor and destructor, and accessors and
modifiers.
Estimated Time to Completion: < 5 hours
Task
Write a program in Microsoft Visual C++
that simulates a Coke vending machine. You must do the
following:
25%
Write the interface (header file) for a Coke Vending Machine
class which has the following characteristics:
·
Six different types of soda (a count of how many cans are
available for each type)
·
An attribute cash which is a float that contains the
amount of money in the vending machine
·
A constant MAX_CANS which defines the maximum number of cans for
each type of soda (assume that all types of soda have the same
maximum)
·
A method DisplayTypes which prints up all the types of
soda currently available (all types which have at least one can
available)
·
A method Vend that takes in a type of soda via a by-value
parameter. After making sure that there is an available can
of this type (print an error if there is not an available can),
this method must decrement the amount of that type of soda by
one, add $0.75 to the cash attribute, and print
Enjoy your XXX where XXX is the type of soda vended.
·
A method Stock that takes in a type of soda via a by-value
parameter and sets the number of the specified type of soda to
the maximum. This method should print XXX all
stocked! where XXX is the type of soda to be stocked.
·
A method WithdrawCash which decrements the cash
attribute to zero (0) and prints N emptied from
machine where N is the amount of cash in the machine before
it was emptied.
·
A constructor that initializes the machine to be full of each
type of soda and have no money. The constructor should
print Im alive when it is finished.
·
A destructor that empties all of the sodas from the machine, sets
the cash attribute to zero (0), and prints Going
offline now when it is finished.
75%
Write an implementation file for all of the above-listed
characteristics.
100%
Write a main algorithm driver file which presents the user with a
menu of options (show available sodas, vend, stock, withdraw, or
quit) and reads in and processes the users selection until
the user selects quit.
Deliverable
Three files: a CPP file containing the
class implementation, an H header file containing the class
interface, and a CPP file which contains the driver (main).
Any submission that doesnt compile
or terminates ugly will receive no credit.
Project 3: Money, Money Everywhere
Objective
To explore inheritance and polymorphism
Estimated Time to Completion: 10 hours
Task
Write a class hierarchy that simulates a
banking system.
Write a class called BankAccount that
has the following attributes and methods
- An
attribute Balance which contains the amount of
money in the account
- Methods
to Withdraw, Deposit, GetBalance,
and constructors and destructors as needed
- The
class should not allow the users balance to go
below 0 as a result of a withdraw
- The
balance should be initially 0 or whatever value is passed
to the constructor
- Any
other methods or attributes as you deem appropriate
Write a class called MoneyMarketAccount
that inherits from BankAccount and has the following attributes
and methods
- An
attribute InterestRate which contains the annual
percentage earned
- An
attribute MinimumBalance which contains the
minimum amount of money the account must have in it
- A method
to AddInterest, and constructors and destructors
as needed
- AddInterest
should see if the minimum balance is in the account.
If it is, then add the interest earned to the balance; if
there isnt enough money in the account, assess a
$20 fee (note that the balance can go below 0 because of
fees).
- Interest
should default to 2.5 or whatever value is passed to the
constructor
- Minimum
balance should default to 500 or whatever value is passed
to the constructor
- Any
other methods or attributes as you deem appropriate
Write a main algorithm that does the
following
- Create a
MoneyMarketAccount object (ask the user for initial
balance, interest rate, and minimum balance)
- Repeat
the following until the user selects quit
- Print
a menu of choices which contains
- Show
account balance
- Deposit
money
- Withdraw
money
- Add
interest
- Quit
- Process
the users choice, asking for any
information as needed and modifying the object
Things to consider
- You
should do input checking from the user such that they
cant deposit a negative number or withdraw a
negative number (effectively cheating the system into
depositing when it should be withdrawing)
- Please
make your submission file as clear as possible by using
good whitespace and comment lines
Deliverable
One file: a CPP file containing the
class headers, implementations, and a driver main.
Any submission that doesnt compile
or terminates ugly will receive no credit.
Project 4: Let the Games Begin
Objective
To explore the Standard Template Library
Estimated Time to Completion: 15 hours
Task
Write a class that simulates a deck of
cards.
Write a class called Card that has
the following attributes and methods
- An
attribute Face which contains the face of the card
(Ace, Two, Three,
Ten, Jack,
Queen, King)
- An
attribute Suit which contains the suit of the card
(Spades, Diamonds,
Clubs, Hearts)
- An
attribute Value which contains the point value of
the card (assume ace=1 always); non-face cards have a
value equal to their face value; face cards have a value
of 10.
- A stream
output methods (overload the << operator) to
display the card like Jack of Hearts
Write a class called Deck that has
the following attributes and methods
- An
attribute which stores a vector of 52 Card
objects (simulate a deck with 52 unique cards)
- A method
to Shuffle which will randomize the deck (full of
52 cards). Consider the following helpful
algorithm:
- Start
with a full, un-shuffled deck
- Loop
for each card in the deck
- Generate
a random number (1-52)
- Swap
the card with the random location
- (of course,
you can always use the built-in STL shuffle method - HINT HINT!)
- A method
to DisplayCards which will print out all the cards
in the deck
- A method
DealCard which will return a Card
the topmost card on the deck (and remove it from the
deck)
- Constructors
and destructors as needed (the deck should initially be
full of cards)
- Any
other methods or attributes as you deem appropriate
Note you may use any Vector STL
function or algorithm as you see fit.
Write a main algorithm that does the
following
- Create a
Deck object
- Repeat
the following until the user selects quit
- Shuffle
deck
- Deal
two cards to user and two cards to computer
- Display
users two cards and display one of the
computers cards. Also display the
users score (sum card values).
- Repeatedly
ask user if they want to stay or
hit (adding a card to their hand and
redisplaying the hands if they choose
hit) until they bust (go
over 21) or stay
- When
the user stays
- Hit
for the dealer until they
bust (go over 21) or
match/exceed the players score
- (Ties
go to dealer)
- Determine
winner of hand
- Keep
track of how many hands user and computer have
won
- Print
overall winner (dealer or user) based upon total # of
hands won.
Things to consider
- Please
make your submission file as clear as possible by using
good white-space and comment lines.
- HINT - Use global CONST
ARRAYs for the output strings (ask me if you don't "get" this
hint)
- Youll
probably want to keep vectors to represent the
dealers and players hands.
- %10+
extra credit if you make an Aces value be 1 or 11
depending upon which would help the
users/dealers hand
- %10+
extra credit if you improve the dealers turn by
having him stay on 15 and doesnt
know about the first card in the
players hand (i.e. improve the realism/heuristics
of the dealers turn)
- Here's my solution for
your enjoyment.
Deliverable
One file: a CPP file containing the
class headers, implementations, and a driver main.
Any submission that doesnt compile
or terminates ugly will receive no credit.
Project 5: C#
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:
- You must have an "About" dialog box that displays the title of
the application and your name. This dialog should also display an
"upside down" card (i.e. the card back) of the selected card set
(see below).
- You must have a "Select Card Set" dialog box that presents the
user with at least 4 card set graphics and allows the user to select the
card set to use. If the user hits "cancel", then the dialog
box should close without changing the card set. If the user clicks a
card back, then the active card set graphic should change to the selected
graphic.
- You must have a main game interface that shows the dealer's and the
player's cards (max of 5 per player). Upon dealing a new
"hand," one card should be shown face up for the dealer and one
card should be shown face down for the dealer; the user should have 2 cards
face up. Your main game interface should also:
- Display the number of games the dealer has won
- Display the number of games the player has won
- Display the total points in the player's hand
- Display the total points in the dealer's hand (all points showing - not
the "face down" card)
- Display the number of games that were ties (assuming that the
"track ties" option is selected - see below)
- Your main game interface should have a main menu with "File",
"Options" and "Help" selections. Your main menu
should allow:
- The user to start a new game, resetting the scores
- The user to Quit (and prompt for confirmation before quitting)
- The user to pick a new card set (see "Select Card Set" dialog
above)
- The user to show the "About" dialog
- The user to set options:
- Track ties, or let the dealer win all ties (if the "track
ties" option is selected, the ties information should be displayed)
- Whether the dealer must get 15 or more points, or allow the dealer to
stay on lower than 15
- Whether aces are worth only 11 or allow the computer to calculate
whether each ace should be valued at 1 or 11 (this option is extra
credit, so you don't have to do this if you don't want the extra credit)
- You must have a "Select name" dialog box that asks the user for
their name. This dialog box must show an "upside down" card
(i.e. the card back) from the selected card set.
- Your program should allow the user to "hit" or "stay"
until they bust (go over 21). Once the user "stays", the
dealer takes his turn. The dealer should try and beat the user, taking
cards until he beats the player's score or busts. Then calculate the
winner and display a message to the user, allowing them to play another hand
or quit the game.
- If the player (or dealer) gets 5 cards without busting, consider this akin
to getting 21 (equal to getting 21 points)
Things to consider:
- You don't have to get fancy and use STL-style classes to manage your
collections, but I would point you to the ArrayList and ImageList classes to
help. Also, you might find the "tag" attribute useful in
storing information about the card's value.
- Be creative and have fun. I'm providing card images for you, but
please feel free to create your own if you'd like
- +10% extra credit if you implement the ace value of 1 or 11 rather than
just always 11.
- Here's my running
program (first install the .Net Platform) for your information.
Your solution can be different so long as you fulfill the above
requirements.
- You may use these card
images (all 73x97) or use your own.
Deliverable
You will demo your finished project in class on 7/24.