Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 07 / Person / Person.cpp
diff options
context:
space:
mode:
Commit959bc760ae370e07d00d68db34e958e032278a44 (patch)
Author
 angeld55 <angel_dimitriev@abv.bg>
2021-04-09 22:39:04 +0300
Committer
 angeld55 <angel_dimitriev@abv.bg>
2021-04-09 22:39:04 +0300
Files9d1a268fccbfa8a3f1f8eebc9ebe71747d8031ff /Sem. 07/Person/Person.cpp
Object-oriented_programming_FMI-959bc760ae370e07d00d68db34e958e032278a44.tar
Object-oriented_programming_FMI-959bc760ae370e07d00d68db34e958e032278a44.tar.gz
Object-oriented_programming_FMI-959bc760ae370e07d00d68db34e958e032278a44.zip
Parentaa62ba9f38f5fe9074d9ebecf037d9a084b03950 (diff)
sem 7
1 files changed, 40 insertions, 0 deletions
-rw-r--r--Sem. 07/Person/Person.cpp40
diff --git a/Sem. 07/Person/Person.cpp b/Sem. 07/Person/Person.cpp
new file mode 100644
index 0000000..2786671
--- /dev/null
+++ b/Sem. 07/Person/Person.cpp
@@ -0,0 +1,40 @@
+#include <iostream>
+#include "Person.h"
+
+Person::Person(const char* name, int age)
+{
+ setName(name);
+ setAge(age);
+}
+
+
+void Person::setName(const char* name)
+{
+ if (strlen(name) >= 20)
+ {
+ strcpy(this->name, "Unknown");
+ }
+ else
+ {
+ strcpy(this->name, name);
+ }
+}
+
+void Person::setAge(int age)
+{
+ if (age<0 || age > 120)
+ age = 40;
+ this->age = age;
+}
+const char* Person::getName() const
+{
+ return name;
+}
+int Person::getAge() const
+{
+ return age;
+}
+void Person::print()
+{
+ std::cout << name << " " << age << std::endl;
+} \ No newline at end of file