forked from ivogeorg/ucd-csci2312-pa4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exceptions.cpp
120 lines (100 loc) · 2.92 KB
/
Exceptions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//
// Created by Nikki on 4/2/2016.
//
#include <iostream>
#include "Exceptions.h"
using std::endl;
namespace Gaming
{
//__name setter for Gaming Exceptions
void GamingException::setName(std::string name)
{
__name = name;
}
// insertion operator for Gaming Exceptions
std::ostream &operator<<(std::ostream &os, const GamingException &ex)
{
ex.__print_args(os);
return os;
}
/*
* Dimension Exceptions Class Constructor
* --Derived class of Gaming Exceptions
*/
DimensionEx::DimensionEx(unsigned expWidth, unsigned expHeight, unsigned width, unsigned height):
__exp_width(expWidth), __exp_height(expHeight), __width(width), __height(height){}
//getters
unsigned DimensionEx::getExpWidth() const
{
return __exp_width;
}
unsigned DimensionEx::getExpHeight() const
{
return __exp_height;
}
//returns the message about the dimensions exception for width
unsigned DimensionEx::getWidth() const
{
return __width;
}
//returns the message about the dimensions exception for height
unsigned DimensionEx::getHeight() const
{
return __height;
}
/*
* Insufficient Dimensions Exception Class Constructor
* --Derived class of Dimension Exception
*/
InsufficientDimensionsEx::InsufficientDimensionsEx(unsigned minWidth, unsigned minHeight,
unsigned width, unsigned height): DimensionEx(minWidth, minHeight, width, height)
{
this->setName("InsufficientDimensionsEx");
}
//Insufficient Dimensions Exception Class print arguments
void InsufficientDimensionsEx::__print_args(std::ostream &os) const
{
os << InsufficientDimensionsEx::getName() << "(minWidth=" << getExpWidth() << ", minHeight=" << getExpHeight()
<< ", width=" << getWidth() << ", height=" << getHeight() << ")";
}
/*
* Out Of Bounds Exception Class Constructor
* --Derived class of Dimension Exception
*/
OutOfBoundsEx::OutOfBoundsEx(unsigned maxWidth, unsigned maxHeight, unsigned width
, unsigned height): DimensionEx(maxWidth, maxHeight, width, height)
{
this->setName("OutOfBoundsEx");
}
//Out of Bounds Exception Class print arguments
void OutOfBoundsEx::__print_args(std::ostream &os) const
{
os << OutOfBoundsEx::getName() << "(maxWidth=" << getExpWidth() << ", maxHeight=" << getExpHeight()
<< ", width=" << getWidth() << ", height=" << getHeight() << ")";
}
void PositionEx::__print_args(std::ostream &os) const
{
os << PositionEx::getName() << " ," << endl;
}
PositionEx::PositionEx(unsigned x, unsigned y):
__x(x), __y(y)
{}
PositionNonemptyEx::PositionNonemptyEx(unsigned x, unsigned y):
PositionEx(x, y)
{
this->setName("PositionNonemptyEx");
}
PositionEmptyEx::PositionEmptyEx(unsigned x, unsigned y):
PositionEx(x, y)
{
this->setName("PositionEmptyEx");
}
void PosVectorEmptyEx::__print_args(std::ostream &os) const
{
os << PosVectorEmptyEx::getName() << endl;
}
PosVectorEmptyEx::PosVectorEmptyEx()
{
this->setName("PosVectorEmptyEx");
}
}