1.
Your task is to develop a
C++ class called DungeonCrawl which represents a simple grid based game board
(20 x 6 cells). Each grid cell contains an ASCII character to represent its
content. A cell can contain a trap (T), treasure (X), player (@) or empty cell
(.). A valid game board must contain a single player, a single treasure and the
number of traps is a parameter of the game. Your class definition should use a
two-dimensional STL Vector to represent the game board. You will need to
include several functions to implement the game itself: · an
initialiser function to randomly place all the required pieces on the board · an
output function to print the current game board to the console · a
collision detection function to check whether the player has either found the
treasure or fallen into a trap · a player movement function which adjusts the players position on
the game board depending on which key the user presses:
w – move up
s – move
down
a – move left
d – move right
NOTE: the game
board is toroidal, e.g. if a player steps off the left side of the board they
appear at the same row on the right side of the board.
2.WRITE A PROGRAM TO STORE DETAILS OF ALL YOUR
CLASSMATES. YOU SHOULD USE A MAP WHOSE ENTRIES USE STUDENT IDS AS KEY VALUES
AND AN INFORMATION OBJECT AS DATA VALUES. YOU ARE FREE TO INCLUDE WHATEVER
INFORMATION YOU THINK IS RELEVANT IN THIS INFORMATION OBJECT. YOU SHOULD
PROVIDE A SIMPLE MENU SYSTEM WHICH HAS 5 OPTIONS:
·
ADD NEW STUDENT TO THE CLASS
·
REMOVE AN STUDENT FROM THE CLASS
·
PRINT ALL STUDENTS IN THE CLASS
·
CLEAR THE CLASS LIST
·
EXIT
3.Governments and companies worldwide are
becoming increasingly concerned with carbon footprint (annual release of carbon
dioxide into the atmosphere) from buildings burning various types of fuels for
heat, vehicles burning fuels for power, and the like. Many scientists blame
these greenhouse gases for the phenomenon called global warming. This task
involves creating several classes to model this phenomenon using inheritance
and polymorphism. Create three classes (Building, Car and Bicycle) which are
initially unrelated by inheritance. Give each class some appropriate attributes
and behaviour that it does not have in common with the other classes. Create an
abstract class called CarbonFootprint with only one pure virtual function
called getCarbonFootprint(). Make each of your classes inherit from the
CarbonFootprint class and implement a getCarbonFootprint() function for each
class. Use the internet to find a realistic carbon footprint value for each of
them. Write a small application that creates an instance of each class. Create
a vector of pointers to CarbonFootprint objects and add the address of each
instance to the vector. Next, iterate over the vector (using the at() function
rather than the [] operators) and polymorphically invoke the
getCarbonFootprint() function and output the objects carbon footprint.
4. For the first exercise you should make use of the LinkedList class
definition .Write a program that creates a linked list of bunny objects. You
must not use the STL List for this task. Each bunny object must have the
following data:
· Sex: Male, Female (random at creation 50/50)
· colour: white, brown, black, spotted
· age : 0-10 (years old)
· Name :
randomly chosen from a list of 10 bunny names (choice these yourself)
5. Write a program that creates a
deck of cards using C++ two classes: Deck and Card. Your classes should include
the following public interfaces:
Deck
·
void shuffleDeck()
·
Card dealCard()
·
bool hasCard()
·
bool isShuffled()
Card
·
void printCard()
·
int getSuit()
·
int getRank()
You will need to decide what
member variables will be required for each of these classes. Hint: you will
need to decide which STL container to use for the deck of cards (such as
vector, deque or set).
Now that you have a way to
represent a deck of cards you should choose your favourite card game and write
a simple implementation of that card game. Example card games include Stud
Poker, Blackjack and Snap! Clearly, you will need to create a Player class and
will probably a Pile class to represent those cards face up on the playing
surface. You may also need to add more member functions and variables to your
existing Deck and Card classes depending on the card game you choose to
develop.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
23 | 24 | 25 | 26 | 27 | 28 | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 1 | 2 | 3 | 4 | 5 |
Get Free Quote!
447 Experts Online