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 you’re 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 doesn’t 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 “I’m 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 user’s 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 doesn’t compile or terminates “ugly” will receive no credit.

 

 

Project 3: “Hacker’s Delight”

Objective

 

Define a program that demonstrates knowledge of composition, dynamic allocation with new and delete, and friend functions.

Estimated Time to Completion: < 3 hours

Task

 

Write a program in Microsoft Visual C++ that simulates a simple building.  You must do the following:

 

25%      Write the interface (header file) for an ITBuilding class which has the following characteristics:

 

·         An private attribute DownstairsMachine which is a vending machine (from project 2)

·         A constructor that prints “Building operational” when it is finished.

·         A destructor that prints “Building closing” when it is finished.

·         Has a friend function called HackerStudentStealsCoke

 

50%      Write an implementation file for all of the above-listed characteristics.

 

100%    Write a main algorithm driver file which does the following

·         Creates a pointer to an ITBuilding

·         Instantiates the ITBuilding using the new command

·         Calls the HackerStudentStealsCoke function

·         Destroys the ITBuilding using the delete command

·         Write the HackerStudentStealsCoke function which simply calls the vend method of the DownstairsMachine attribute of the ITBuilding object; you can vend any type of soda you’d like… just hardcode it in as ‘0’ or ‘1’ or whatever you’d like.

 

Note – if you’d like, use the VendingMachine class provided on the 2313 site rather than your own.

 

To make sure that you’re on track (yeah – it’s that simple!), this is all your program should print (or something real similar):

 

I'm alive.

Building operational.

Enjoy your Coke!

Building closing.

Going offline now.

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).  Please don’t submit your VendingMachine class – I’ve already got that, and it should be the exact same as from Project 2!

 

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

 

Project 4: “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

 

Write a class called MoneyMarketAccount that inherits from BankAccount and has the following attributes and methods

 

Write a main algorithm that does the following

 

Things to consider

Deliverable

 

One file: a CPP file containing the class headers, implementations, and a driver main.

 

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

 

Project 5: “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

 

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

 

Note – you may use any Vector STL function or algorithm as you see fit.

 

Write a main algorithm that does the following

 

Things to consider

Deliverable

 

One file: a CPP file containing the class headers, implementations, and a driver main.

 

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

 

 

Project 6: “GUI Gaming”

Objective

 

To explore MFC programming

Estimated Time to Completion:  15-25 hours

Task

Convert your console-based Blackjack application to a GUI (Graphical User Interface) application using MFC.

NOTE - if you want, please feel free to use my implementation of the Card, Deck, and Hand classes (and look at my main algorithm for info too). Don't waste your time on this project trying to make up for mistakes in your implementation of Project 5 - the point here is to learn MFC, not redo the Vector and STL tasks.

The interface is up to you, but you must have the following:

Check out my working demo for some UI hints.

Deliverable

 

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