Inheritance Project ..

Please support our Game Development advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2005
Posts: 2
Reputation: Qatar is an unknown quantity at this point 
Solved Threads: 0
Qatar Qatar is offline Offline
Newbie Poster

Inheritance Project ..

 
0
  #1
Apr 28th, 2005
Hello ...


I must do a mini project on Inheritance ..
It's about 2-D and 3-D shapes..


The base class is point ..
and we must define as many derived classes as we could such as circle .. rectangle .. triangle .. Cylender .... and so on !


The most clsses and functions we include the most grades we will get ..


can you please help me in that .. Ideas ... articles .... Tutorials ... Open codes or any thing related ..


Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 219
Reputation: BountyX is an unknown quantity at this point 
Solved Threads: 8
BountyX's Avatar
BountyX BountyX is offline Offline
Code Guru

Re: Inheritance Project ..

 
0
  #2
Apr 29th, 2005
are you doing it in opengl? or is it like turtle graphics
A Hacker's Mind:
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes..." - J.D.Salinger
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 2
Reputation: Qatar is an unknown quantity at this point 
Solved Threads: 0
Qatar Qatar is offline Offline
Newbie Poster

Re: Inheritance Project ..

 
0
  #3
Apr 29th, 2005
It is an open project ..
the teacher didn't put any rules for it ..
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,858
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: Inheritance Project ..

 
0
  #4
Apr 29th, 2005
>The base class is point .
Inheritance isn't the right solution for point. A shape is not a point. A shape has one or more points, so containment is a better solution. point should be a stand-alone class. I really hate the shape abstraction as a means of introducing inheritance, but consider this:
struct Point {
  int x, y;
};

class Shape {
  /* No points */
public:
  virtual void draw() const { cout<<"Shape"<<endl; }
};

class Ellipse: public Shape {
  Point center;
  int radius;
public:
  virtual void draw() const { cout<<"Ellipse"<<endl; }
};

class Rectangle: public Shape {
  Point top_left;
  Point bottom_right;
public:
  virtual void draw() const { cout<<"Rectangle"<<endl; }
};
It's much harder to work out a coherent hierarchy if all of the shapes derive from Point.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2784 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Game Development
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC