-
Notifications
You must be signed in to change notification settings - Fork 0
/
Attribute.cpp
41 lines (32 loc) · 920 Bytes
/
Attribute.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
/*
File: Attribute.cpp
Authors: Grace Coffman, Sidian Wu, Wesley Tang
Department of Computer Science
Texas A&M University
This file contains the function definitions for the class "Attribute".
*/
#include "Attribute.h"
Attribute::Attribute(std::string n, int in) throw (InvalidType, EmptyName){
while(!n.empty()) //strip space
{
if(n.at(0) == ' ')
n.erase(0,0);
else
break;
}
if(n.empty()) throw EmptyName();
name=n;
if( in > 5 || in < 0) throw InvalidType();
ident=in;
}
bool operator== (Attribute &a, Attribute &b) {
return ( ( a.get_ident() == b.get_ident() ) && ( a.get_name() == b.get_name() ) );
}
void Attribute::display(string& output)
{
//std::cout << get_name() << "(" << get_ident() << ") \t";
char temp[5];
itoa(get_ident(), temp, 10);
output.append(get_name()); output.append("(");
output.append(temp); output.append(")");
}