Skip to content

Implementation of the "SmartPointer" assignment in the SS2021 PR2 course (UNIVIE)

License

Unknown, Unknown licenses found

Licenses found

Unknown
license.cpp
Unknown
license.h
Notifications You must be signed in to change notification settings

fini03/smartpointer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#include"license.h"
using namespace std;
License::License(std::string name, unsigned int salary) : name{name}, salary{salary} {
	if(name.empty()) {
		throw std::runtime_error ("Name is empty!\n");	
	}
	if(salary <= 0) {
		throw	std::runtime_error ("Salary is negative!\n");
	}
}
std::string License::get_guildname() const {
	return name;
}
unsigned int License::get_salary() const {
	return salary;
}
bool License::valid() const {
	return counter <= 3;
}
bool License::use() {
	if(!valid()) {
		return false;	
	}
	++counter;
	return true;
}
std::ostream& License::print(std::ostream& o) const {
	return o << "[License for " << name << ", Salary: " << salary << ", Used: " << counter << ']';
}
std::ostream& operator<<(ostream& o, const License& l) {
	return l.print(o);
}

About

Implementation of the "SmartPointer" assignment in the SS2021 PR2 course (UNIVIE)

License

Unknown, Unknown licenses found

Licenses found

Unknown
license.cpp
Unknown
license.h

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages