Yurttas/PL/OOL/Cplusplus/F/04/02/03/00/Land.cpp

From ZCubes Wiki
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   Land.cpp
14*/
15
16
17#include <cstring>
18
19#include <iostream>
20
21using namespace std;
22
23#include "Land.h"
24
25Land::
26Land() :  Mammals(),
27          food('h') {
28}
29
30Land::
31Land(const Land& a) : Mammals(a),
32                      food(a.food) {
33}
34
35Land::
36~Land() {
37}
38
39Land&
40Land::
41operator=(const Land& 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  food = a.food;
53
54  return *this;
55}
56
57char
58Land::
59get_food() const {
60  return food;
61}
62
63void
64Land::
65set_food(const char a) {
66  food = a;
67}
68
69void
70Land::
71print() const {
72  cout << "Name: " << name << endl;
73  cout << "Age: " << age << endl;
74  cout << "Legs: " << legs << endl;
75  cout << "Food: " << food << endl;
76  cout << endl;
77}