Class Diagrams and Stuff C++

Get help on programming - C++, Java, Delphi, etc.
Post Reply
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Class Diagrams and Stuff C++

Post by DarkRanger »

Hi guys,

I am so lost with this, I don't even know where to begin. This is not a request for someone to do my homework, just a request for someone to nudge me in the right direction.

On completion of our 6th practical in C++ we must:
be able to interpret a UML class diagram and understand the association concepts of:
● generalisation – inheritance
● aggregation
● dependencies
understand the concepts of and be able to implement in C++:
● inheritance
● polymorphism – virtual
● abstract classes – pure virtual

Here is the image of the UML diagram that we have been given:

Image

Now, our first task is laid out as follows:

Step 1: Implement the Obstacle Class Hierarchy
● Create a file called Obstacle.h
● Implement the classes of the Obstacle class hierarchy in this file.
● The action operation of NastyWeapon writes Nasty Weapon to standard out and Puzzle writes Puzzle to standard out.
● Write a main program to test your classes. An example of such a test program is given by:

Code: Select all

#include "Obstacle.h"
int main(){
  Obstacle *p = new Puzzle;
  Obstacle *n = new NastyWeapon;
  p->action();
  n->action();
  delete p;
  delete n;
  return 0;
}
● The output generated by this program is:

Code: Select all

Puzzle
Nasty Weapon
Lets start of by saying I have no idea what the p->action(); statement does.

The only thing that I have done up to this point is I've created the Obstacle.h file, although that file is still empty.

Please Help me...
Image
Post Reply