Skip to content

Commit e7d458b

Browse files
committed
first commit
0 parents  commit e7d458b

File tree

9 files changed

+216
-0
lines changed

9 files changed

+216
-0
lines changed

angle.h

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include "ray.h"
2+
class angle{
3+
public:
4+
angle();
5+
angle(unsigned long d);
6+
angle(ray a, ray b);
7+
8+
protected:
9+
ray one;
10+
ray two;
11+
unsigned long dimensions;
12+
};
13+
14+
angle::angle()
15+
{
16+
}
17+
18+
angle::angle(unsigned long d)
19+
{
20+
one = ray(d);
21+
two = ray(d);
22+
dimensions = d;
23+
}
24+
25+
angle::angle(ray a, ray b)
26+
{
27+
if(a.dim()==b.dim())
28+
{
29+
//add check that a.one = b.one
30+
one = a;
31+
two = b;
32+
dimensions=a.dim();
33+
}
34+
else
35+
{
36+
cout<<"Ray dimension mismatch"<<endl;
37+
}
38+
}

circle.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Circle
2+
{
3+
public: Circle();
4+
void setRadius(line r);
5+
segment getRadius();
6+
segment getDiameter();
7+
void getCircumference();
8+
void getArea();
9+
protected:
10+
segment radius;
11+
private:
12+
};

line.h

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "point.h"
2+
class line{
3+
public:
4+
line();
5+
line(unsigned long d);
6+
line(point a, point b);
7+
unsigned long dim(void);
8+
protected:
9+
point one;
10+
point two;
11+
unsigned long dimensions;
12+
};
13+
14+
line::line()
15+
{
16+
}
17+
18+
line::line(unsigned long d)
19+
{
20+
one = point(d);
21+
two = point(d);
22+
dimensions = d;
23+
}
24+
25+
line::line(point a, point b)
26+
{
27+
if(a.dim()==b.dim())
28+
{
29+
one = a;
30+
two = b;
31+
dimensions=a.dim();
32+
}
33+
else
34+
{
35+
cout<<"Points Dimension mismatch"<<endl;
36+
}
37+
}
38+
unsigned long line::dim(void)
39+
{
40+
return dimensions;
41+
}

main

99.3 KB
Binary file not shown.

main.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using namespace std;
2+
#include <iostream>
3+
#include "angle.h"
4+
5+
int main()
6+
{
7+
point a(2);
8+
point b(2);
9+
10+
a.set_dim(1,0);
11+
a.set_dim(2,0);
12+
13+
b.set_dim(1,7);
14+
b.set_dim(2,24);
15+
16+
ray myseg(a,b);
17+
18+
19+
return 0;
20+
}

point.h

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <vector>
2+
3+
class point{
4+
public:
5+
point();
6+
point(unsigned long);
7+
double get_dim(unsigned long);
8+
void set_dim(unsigned long, double);
9+
unsigned long dim(void)
10+
{return dimensions; }
11+
12+
protected: unsigned long dimensions;
13+
vector<double> dimension;
14+
};
15+
point::point()
16+
{
17+
}
18+
point::point(unsigned long d)
19+
{
20+
dimensions=d;
21+
dimension= vector<double>(d);
22+
}
23+
double point::get_dim(unsigned long dim)
24+
{
25+
return dimension.at(dim-1);
26+
}
27+
void point::set_dim(unsigned long dim, double value)
28+
{
29+
if(dim <= dimensions)
30+
{
31+
dimension.at(dim-1)=value;
32+
}
33+
else
34+
{
35+
cout<<"Dimensions out of bounds"<<endl;
36+
}
37+
}

polygon.h

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class Polygon
2+
{
3+
public:
4+
void set_sides(int);
5+
void set_angles(int);
6+
void set_vertices(int);
7+
void set_diagonals(int);
8+
9+
protected:
10+
int sides, angles, vertices, diagonals;
11+
};
12+
13+
void polygon::set_sides(int s)
14+
{
15+
sides = s;
16+
}
17+
void polygon::set_angles(int a)
18+
{
19+
angles = a;
20+
}
21+
void polygon::set_vertices(int v)
22+
{
23+
vertices = v;
24+
}
25+
void polygon::set_diagonals(int d)
26+
{
27+
diagonals = d;
28+
}

ray.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "line.h"
2+
class ray : public line{
3+
public:
4+
ray()
5+
{
6+
}
7+
ray(unsigned long d) : line(d)
8+
{
9+
}
10+
ray(point a, point b) : line(a,b)
11+
{
12+
}
13+
private:
14+
};
15+

segment.h

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "line.h"
2+
#include <math.h>
3+
#include <cmath>
4+
class segment : public line{
5+
public:
6+
segment(unsigned long d) : line(d)
7+
{
8+
}
9+
segment(point a, point b) : line(a,b)
10+
{
11+
}
12+
double length(void)
13+
{
14+
double sum=0;
15+
unsigned int i=1;
16+
for(i=1;i<=dimensions;i++)
17+
{
18+
sum+=pow((two.get_dim(i)-one.get_dim(i)),2);
19+
}
20+
21+
return sqrt(sum);
22+
}
23+
private:
24+
};
25+

0 commit comments

Comments
 (0)