Thread: Help with program?

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    3

    Help with program?

    Hi all,

    i was wondering if anyone could please help me out as i'm am struggling with programming. Our Lecturer has given us this assignment and i need help getting started. I'm asking on here because our lecturer isn't very helpful and doesn't explain things very well. (By the way i'm am a real novice at programming)

    The start of the assignement is as follows:

    Create a base class named ‘Quadrilateral’ that contains 4 float attributes (with a ‘protected’ access specifier) called side1, side2, side3, side4. The member functions (methods) must consist only of the following:

    1. a four-argument constructor with default values of 1.0 for all attributes
    2. a function area( ) to return a float value of ‘-1’ since the area is indeterminate.
    3. a function perimeter( ) to return a float value, the sum of all four attributes.
    4. a function getSide1( ) to return side1.
    5. a function name( ) to return a char pointer (char*) initialized to “Quadrilateral”.
    6. a destructor function.

    Create a derived class named ‘Rectangle’ with public inheritance from Quadrilateral. The member functions (methods) must consist only of the following:

    1. a two-argument constructor with default values of 1.0. The first argument is assigned to ‘side1’ and ‘side3’, the second argument is assigned to ‘side2’ and ‘side4’.
    2. a function area( ) to return a type float from the product of size1 and size2.
    3. a function name( ) to return a char pointer (char*) initialized to “Rectangle”.
    4. a destructor function.

    If any could please help i would really appreciate it
    Thanks for your time

    Mark.

  2. #2
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Give it a try on your own. We are here to guide and help you, not think for you. Show some effort and we'll be glad to help you.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    One of your countrymen wrote a very good book on C++. It's called Ivor Horton's Beginning C++. Read the chapter on classes and the chapter on inheritance, and you'll be able to do that program in a snap. Good luck.

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    3

    what i've done so far

    this is what i've done so far, could anyone please tell me if i'm on the right lines?
    Cheers Mark.

    Code:
    // Mark Gaskell
    // Module: Prog1B LCT 1006
    // Filename: Part1
    
    #include <iostream.h>
    
    int main()
    
    class Quadrilateral
    
    {
      protected:
          // Constructor definition 
      Quadrilateral(float side1, float side2, float side3, float side4)
    	
    
    
    public:
    	char* name();
    	float getSide1();
    	float perimeter();
    	float area();
    	~Quadrilateral();
    }
    
    
    float Quadrilateral::area()
    {
    
    }
    
    float Quadrilateral::perimeter()
    {
    
    }
    
    float Quadrilateral::getSide1()
    {
    
    }
    
    char* Quadrilateral::name()
    {
    
    }
    Last edited by MarkGaskell20; 05-01-2003 at 04:52 AM.

  5. #5
    Student Forever! bookworm's Avatar
    Join Date
    Apr 2003
    Posts
    132
    Boy, thats a big favor you r asking for buddy!
    I have something that might help u.
    ( U r very lucky I'm in a good mood right now,or else I would have copied and pasted RoD's reply )

  6. #6
    Registered User
    Join Date
    May 2003
    Posts
    3

    Thanks a lot

    Just sayin thanks a lot for that mate, you've been a great help
    I just needed something to get me on way that's all

    Cheers Mark

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM