Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,769 changes: 2,769 additions & 0 deletions Doxyfile

Large diffs are not rendered by default.

134 changes: 134 additions & 0 deletions documentation/Classes/class_dog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
---
title: Dog
summary: Represents a dog.

---

# Dog



Represents a dog. [More...](#detailed-description)


`#include <dog.hpp>`

## Public Functions

| | Name |
| -------------- | -------------- |
| | **[Dog](Classes/class_dog.md#function-dog)**(const char * _name)<br>Creates a new [Dog](Classes/class_dog.md). |
| void | **[bark](Classes/class_dog.md#function-bark)**(void )<br>Causes the dog to bark. |
| void | **[run](Classes/class_dog.md#function-run)**(int minutes)<br>Causes the dog to run. |
| void | **[sleep](Classes/class_dog.md#function-sleep)**(int minutes)<br>Causes the dog to sleep. |

## Protected Functions

| | Name |
| -------------- | -------------- |
| bool | **[checkEnergy](Classes/class_dog.md#function-checkenergy)**(int energyToExpend)<br>Checks the dog's energy. |

## Detailed Description

```cpp
class Dog;
```

Represents a dog.

This class keeps track of the dog's energy level, and performs actions for the dog based on how much energy it has. Sleeping regains energy for the dog, while barking and running use energy up.

## Public Functions Documentation

### function Dog

```cpp
Dog(
const char * _name
)
```

Creates a new [Dog](Classes/class_dog.md).

**Parameters**:

* **_name** The dog's name.


Creates a new [Dog](Classes/class_dog.md) named `_name` with half of its maximum energy.


### function bark

```cpp
void bark(
void
)
```

Causes the dog to bark.

Causes the dog to bark if it has enough energy to do so. Barking costs 1 energy to do. If the dog does not have enough energy, then the bark fails.


### function run

```cpp
void run(
int minutes
)
```

Causes the dog to run.

**Parameters**:

* **minutes** Number of minutes for the dog to run.


Causes the dog to run for an amount of time if it has enough energy to run for that long. If the dog does not have enough energy, then the run fails. If the dog cannot complete the full run, no running takes place and no energy is expended. Running costs 3 energy per minute.


### function sleep

```cpp
void sleep(
int minutes
)
```

Causes the dog to sleep.

**Parameters**:

* **minutes** Number of minutes for the dog to sleep.


Sleeping replenishes the dog's energy. The dog regains an amount of energy equal to twice the number of minutes slept. The dog will always sleep, regardless of how much energy it has remaining.


## Protected Functions Documentation

### function checkEnergy

```cpp
bool checkEnergy(
int energyToExpend
)
```

Checks the dog's energy.

**Parameters**:

* **energyToExpend** An amount of energy to check.


**Return**: True if the dog has enough energy, and false otherwise.

Compares an amount of energy with the dog's current available energy. This function can be used to determine if the dog is able to take an action that costs energy.


-------------------------------

Updated on 2022-10-02 at 18:55:10 +0500
28 changes: 28 additions & 0 deletions documentation/Files/dir_68267d1309a1af8e8297ef4c3efbcdba.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: src

---

# src



## Files

| Name |
| -------------- |
| **[src/dog.cpp](Files/dog_8cpp.md#file-dog.cpp)** |
| **[src/dog.hpp](Files/dog_8hpp.md#file-dog.hpp)** |
| **[src/main.cpp](Files/main_8cpp.md#file-main.cpp)** |
| **[src/main.hpp](Files/main_8hpp.md#file-main.hpp)** |
| **[src/utility.cpp](Files/utility_8cpp.md#file-utility.cpp)** |
| **[src/utility.hpp](Files/utility_8hpp.md#file-utility.hpp)** |






-------------------------------

Updated on 2022-10-02 at 18:55:10 +0500
76 changes: 76 additions & 0 deletions documentation/Files/dog_8cpp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: src/dog.cpp

---

# src/dog.cpp






## Source code

```cpp
#include "dog.hpp"
#include "utility.hpp"
#include <stdio.h>

Dog::Dog(const char* _name) : name(_name) {
energy = MAX_ENERGY / 2;
printf("Created %s the dog.\n", name);
}

void Dog::bark(void) {
int energyToExpend = 1;
if (checkEnergy(energyToExpend)) {
energy -= energyToExpend;
printf("%s BARKS!\n", name);
} else {
fprintf(stderr, "%s is too tired to bark.\n", name);
}
}

void Dog::run(int minutes) {
int energyToExpend = multiply(minutes, 3);
if (checkEnergy(energyToExpend)) {
energy -= energyToExpend;
printf("%s runs for %d minute%s.\n",
name,
minutes,
minutes == 1 ? "" : "s");
} else {
fprintf(stderr,
"%s is too tired to run for %d minute%s.\n",
name,
minutes,
minutes == 1 ? "" : "s");
}
}

void Dog::sleep(int minutes) {
int energyToRegain = multiply(minutes, 2);
energy += energyToRegain;
printf("%s sleeps for %d minute%s.\n",
name,
minutes,
minutes == 1 ? "" : "s");
if (energy > MAX_ENERGY) {
energy = MAX_ENERGY;
printf("%s is fully rested.\n", name);
}
}

bool Dog::checkEnergy(int energyToExpend) {
if (energy > energyToExpend) {
return true;
}
return false;
}
```


-------------------------------

Updated on 2022-10-02 at 18:55:10 +0500
67 changes: 67 additions & 0 deletions documentation/Files/dog_8hpp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: src/dog.hpp

---

# src/dog.hpp



## Classes

| | Name |
| -------------- | -------------- |
| class | **[Dog](Classes/class_dog.md)** <br>Represents a dog. |

## Defines

| | Name |
| -------------- | -------------- |
| | **[MAX_ENERGY](Files/dog_8hpp.md#define-max-energy)** |




## Macros Documentation

### define MAX_ENERGY

```cpp
#define MAX_ENERGY 10
```


## Source code

```cpp
#ifndef DOG_HPP
#define DOG_HPP

#define MAX_ENERGY 10

class Dog {
public:
Dog(const char* _name);

void bark(void);

void run(int minutes);

void sleep(int minutes);

protected:
bool checkEnergy(int energyToExpend);

private:
const char* name;

int energy;
};

#endif // DOG_HPP
```


-------------------------------

Updated on 2022-10-02 at 18:55:10 +0500
Loading