Yurttas/PL/OOL/Cplusplus/F/04/02/03/00/Sea.cpp
Jump to navigation
Jump to search
1/*
2 Copyright(C) 2001
3 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4
5 Permission to use, copy, modify, and distribute this
6 software and its documentation for EDUCATIONAL purposes
7 and without fee is hereby granted provided that this
8 copyright notice appears in all copies.
9
10 date : June 1, 2001.
11 author : Salih Yurttas.
12
13 Sea.cpp
14*/
15
16
17#include <cstring>
18
19#include <iostream>
20
21using namespace std;
22
23#include "Sea.h"
24
25Sea::
26Sea(): Mammals(),
27 lives('o') {
28}
29
30Sea::
31Sea(const Sea& a) : Mammals(a),
32 lives(a.lives) {
33}
34
35Sea::
36~Sea() {
37}
38
39Sea&
40Sea::
41operator=(const Sea& a) {
42 if(this==&a) return *this;
43
44 delete [] name;
45
46 name = new char[strlen(a.name)+1];
47 strcpy(name, a.name);
48
49 age = a.age;
50 legs = a.legs;
51
52 lives = a.lives;
53
54 return *this;
55}
56
57char
58Sea::
59get_lives() const {
60 return lives;
61}
62
63void
64Sea::
65set_lives(const char a) {
66 lives = a;
67}
68
69void
70Sea::
71print() const {
72 cout << "Name: " << name << endl;
73 cout << "Age: " << age << endl;
74 cout << "Legs: " << legs << endl;
75 cout << "Lives in: " << lives << endl;
76 cout << endl;
77}