Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Derive a second class

$
0
0
This is only my second C++ assignmet. I have been working on this all day. The question is a 2 part question. the first part is as follows,
A point in the x-y plane is represented by it's x-coordinate and y-cordinate. Design a class, pointType, that can store and proccess a point in the x-y plain.you should then perform operations on the point, such as showing the point, setting the point, returning the x-coordinate and returning the y-coordinate.Also write a test program to test the various operations on the point.

second part.
Every circle has a center and a redius.Given the radius, we can determine the circle's area and circumference.Given the center we can determine the circles position in the x-y plane.The center of a circle is a point in teh x-y plane. Designe a class, circleType that can store a radius and the center of the circle.Because the center is a point in the x-y plane and you designed the class to capture the properties of a point in preceeding exercise. You must derive a class circleType from the class pointType. You should be able to perform the usual operations on a circle, such as setting the radius, printing the redius, calculating and printing the area and circumference, and carring out the usual operations on the center.

I am able to get the first part of the exercie. however I don't know what they mean by writing a test program
As you will see I created a class cicrleType within the same project. However after creating class circleType I get the error "main.cpp|9|circleType.h: No such file or directory"
I am using code blocker. I know that i have to still work on the circleType files which will not be an issue, I just don't know why code blocker is not seeing circleType.h


main.cpp
#include "pointType.h"
#include "circleType.h"
#include <iostream>
using namespace std;

int main()
{
    double Coordinate_x;
    double Coordinate_y;


cout << "Enter the x and y coordinate " << endl;
cin >> Coordinate_x >> Coordinate_y;
cout << "Enter the radus of the circle" <<endl;

cout << "The X and Y Coordinates are: (" <<Coordinate_x <<"," << Coordinate_y<< ")"
<< endl;
cout << "The Area if the circe ";
cout <, "The circumferance of the circke is ";

}




pointType.cpp
#include "pointType.h"
#include <string>
#include <iostream>
/*void pointType::setCoordinate(double x,double y)
{
    Coordinate_x = x;
    Coordinate_y = y;

}*/
void pointType::setCoordinate_x(double Coordinate_x)
{

}

void pointType::setCoordinate_y(double Coordinate_y)
{

}
void pointType::print()const
{

}

pointType::pointType()
{
    double Coordinate_x= 0;
    double Coordinate_y= 0 ;
}



pointType.h
#ifndef POINTTYPE_H_INCLUDED
#define POINTTYPE_H_INCLUDED
/*#pragma once*/
#include <string>
using namespace std;
/*template <class elemType>*/
class pointType
{
public:
   void print()const;
   /*void setCoordinate(double x = 0, double y = 0);*/
   void setCoordinate_x(double Coordinate_x);
   void setCoordinate_y(double Coordinate_y);
   double getCoordinate_x () const;
   double getCoordinate_y ()const;
   pointType(void);
   pointType (double Coordinate_x,double Coordinate_y);
   ~pointType(void);

private:
   double Coordinate_x;
   double Coordinate_y;

};

#endif // POINTTYPE_H_INCLUDED




circleType.h
#ifndef CIRCLETYPE_H
#define CIRCLETYPE_H

#include <pointType.h>


class circleType : public pointType
{
    public:
        void circleType(double Coordinate_x, double Coordinate_y,double Radus );
        void print()const;
        double setAreaOfCircle() const;
        double setCircumference() const;
        double getRadus () const;
        circleType(double Coordinate_x, double Coordinate_y,double Radus);
        ~circleType (void);//rest is from defalut
        circleType();
        virtual ~circleType();

    private:
        double Radus ()const;
        double pie = 3.14;
};

#endif // CIRCLETYPE_H



src\circleType.cpp
#include "circleType.h"
#include "pointType.h"
#include <string>
#include <iostream>

double circleType::getRadus()const
{
  return Radus;  //ctor
}
double circleType::AreaOfCircle () const
{
    return 3.14 * Radus*Radus;
}
double circleType::Circumference () const
{
return 3.14 *2*Radus;
}

circleType::circleType()
{
    //ctor
}

circleType::~circleType()
{
    //dtor
}



Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>