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
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"string": "cpp",
"typeinfo": "cpp"
}
}
109 changes: 109 additions & 0 deletions Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#include "doctest.h"
#include "iostream"
#include "string"
#include "sources/Team.hpp"

using namespace std;
using namespace ariel;

TEST_CASE("Point class")
{
SUBCASE("Constructors")
{
CHECK_NOTHROW(Point(2, 3));
CHECK_THROWS(Point(2, 3));
}
SUBCASE("Functions")
{
Point p1(2, 3);
Point p2(3, 4);
// Distance
CHECK_NOTHROW(p1.distance(p2));
CHECK_EQ(p1.distance(p2), 1);
// Print
CHECK_NOTHROW(p1.print());
string printPoint = p1.print();
CHECK(printPoint == "");
// moveTowards
CHECK_NOTHROW(moveTowards(p1, p2, 1));
Point p3(3, 4);
Point moved = moveTowards(p1, p2, 1);
CHECK_EQ(moved.getX(), p3.getX());
CHECK_EQ(moved.getY(), p3.getY());
// Gettes&Setters
CHECK_NOTHROW(p1.getX());
CHECK_NOTHROW(p1.getY());
Point p4(5, 6);
Point p5(5.0, 6.0);
CHECK_EQ(p4.getX(), p5.getX());
CHECK_EQ(p4.getY(), p5.getY());
p1.setX(5), p1.setY(6);
CHECK_EQ(p4.getX(), p1.getX());
CHECK_EQ(p4.getY(), p1.getY());
}
}

TEST_CASE("Character class")
{
SUBCASE("Constructors")
{
Point p1(1, 2);
string name = "yulia";
CHECK_NOTHROW(Character war1(name, p1, 46));
Character war1(name, p1, 46);
}
SUBCASE("Functions")
{
// isAlive
Point p1(1, 2);
string name = "yulia";
Character war1(name, p1, 110);
CHECK_NOTHROW(war1.isAlive());
CHECK(war1.isAlive());
war1.setHits(0);
CHECK_FALSE(war1.isAlive());
// distance
Point p2(3, 4);
Character war2("Dudi", p2, 110);
CHECK_NOTHROW(war1.distance(war2));
double charDist = war1.distance(war2);
CHECK_EQ(charDist, 1);
// hit
CHECK_NOTHROW(war1.hit(10));
war1.hit(10);
CHECK_EQ(war1.getHits(), 100);
war1.hit(100);
CHECK_FALSE(war1.isAlive());
// getName
CHECK_NOTHROW(war1.getName());
string name1 = war1.getName();
CHECK_EQ(name1, "yulia");
// getLocation
CHECK_NOTHROW(war1.getLocation());
CHECK_EQ(war1.getLocation(), p1);
CHECK_EQ(war2.getLocation(), p2);
// print
CHECK_NOTHROW(war1.print());
string printWarrior = war1.print();
CHECK_EQ(printWarrior, "");
}
}
TEST_CASE("Cowboy class")
{
SUBCASE("Constructors")
{
Point p1(1, 2);
CHECK_NOTHROW(Cowboy c1("yulia", p1));
Cowboy c1("yulia", p1);
CHECK(c1.hasboolets());//Checks if Character and Cowboy constructors combined
CHECK_EQ(c1.getHits(),110);



}
SUBCASE("Functions") {}
}
TEST_CASE("Character class") {}
TEST_CASE("Character class") {}
TEST_CASE("Character class") {}
TEST_CASE("Character class") {}
39 changes: 39 additions & 0 deletions sources/Character.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "Character.hpp"

namespace ariel
{
using namespace std;
Character::Character(string _name, Point _location, int _hits)
: name(_name), location(_location), hits(_hits) {}
bool Character::isAlive()
{
return true;
}
double Character::distance(Character &other)
{
return 0;
}
void Character::hit(int) {}
string Character::getName()
{
return "";
}
Point Character::getLocation()
{
return Point(0, 0);
}
string Character::print()
{
return "";
}
void Character::setHits(int newHits)
{
this->hits = newHits;
}
int Character::getHits()
{
return hits;
}


}
34 changes: 34 additions & 0 deletions sources/Character.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef CHARACTER_H
#define CHARACTER_H

#include <string>
#include "Point.hpp"
//#include "Cowboy.hpp"
//#include "Ninja.hpp"

namespace ariel
{

using namespace std;

class Character
{
private:
string name;
Point location;
int hits;

public:
Character(string, Point, int);
bool isAlive();
double distance(Character &other);
void hit(int);
string getName();
Point getLocation();
virtual string print();
void setHits(int);
int getHits();
};

}
#endif
18 changes: 18 additions & 0 deletions sources/Cowboy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "Cowboy.hpp"

namespace ariel{

Cowboy::Cowboy(string _name, Point _location)
:Character(_name, _location, 110),numOfBullets(6){}
void Cowboy::shoot(const Character *enemy){}
bool Cowboy::hasboolets(){
return true;
}
string Cowboy::print(){
return "";
}
void Cowboy::reload(){}
int Cowboy::getBullets(){
return numOfBullets;
}
}
25 changes: 25 additions & 0 deletions sources/Cowboy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef COWBOY_H
#define COWBOY_H
#include "Character.hpp"

namespace ariel{

class Cowboy : public Character
{
int numOfBullets;

public:
Cowboy(string, Point); // Constractor (created with 6 bullets and 110 hits)
void shoot(const Character *enemy);//if the cowboy is alive, shoot 1 bullet, take 10 hit from enemy.
bool hasboolets();//if exists bullets in stack
virtual string print() override;
void reload();//reload the gun with 6 bullets
int getBullets();
};
}
#endif
//For cowboys: int numOfBullets (created with 6 bullets and 110 hits)
//Functions:
//shoot(Character &enemy), if the cowboy is alive, shoot 1 bullet, take 10 hit from enemy.
//bool hasboolets() - if exists bullets in stack
//void reload() - reload the gun with 6 bullets
13 changes: 13 additions & 0 deletions sources/Ninja.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "Ninja.hpp"


namespace ariel{

Ninja::Ninja(string _name, Point _location, int _hits, int _speed)
: Character(_name, _location, _hits),speed(_speed){}
void Ninja::move(const Character *enemy){}
void Ninja::slash(Character *other){}
string Ninja::print(){
return "";
}
}
26 changes: 26 additions & 0 deletions sources/Ninja.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef NINJA_H
#define NINJA_H
#include "Character.hpp"

namespace ariel{

class Ninja : public Character
{
int speed;

public:
Ninja(string, Point, int, int); // Constractor
void move(const Character *enemy);//moves the dustanse of its speed(???)
void slash(Character *other);//if the ninja is alive and the enemy is at most 1 meter,takes 40 hits from enemy.
virtual string print() override;
};
}
#endif
//For nunjas: int speed, there is 3 types of nunjas:
//YoungNunja - created with speed = 14, 100 hits
//TrainedNinja - created with speed = 12, 120 hits
//OldNinja - created with speed = 8, 150 hits
//Functions:
//void move(Caracter &enemy) - moves the dustanse of its speed(???)
//slash(Character &enemy) - if the ninja is alive and the enemy is at most 1 meter,
// takes 40 hits from enemy.
8 changes: 8 additions & 0 deletions sources/OldNinja.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "OldNinja.hpp"


namespace ariel{

OldNinja::OldNinja(string _name, Point location):Ninja(_name, location, 150, 8){}

}
14 changes: 14 additions & 0 deletions sources/OldNinja.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef OLDNINJA_H
#define OLDNINJA_H
#include "Ninja.hpp"

namespace ariel
{

class OldNinja : public Ninja
{
public:
OldNinja(string, Point);//Constructor created with speed = 8, 150 hits.
};
}
#endif
34 changes: 34 additions & 0 deletions sources/Point.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "Point.hpp"

namespace ariel
{
using namespace std;
Point::Point(double _x, double _y){
x = _x;
y = _y;
}
double Point::distance(Point &other){
return 0;
}
string Point::print(){
return "";
}
Point moveTowards(Point &source, Point &destenation, double distance){
return Point(0,0);
}
double Point::getX(){
return this->x;
}
double Point::getY(){
return this->y;
}
void Point::setX(double newX){
this->x = newX;
}
void Point::setY(double newY){
this->y = newY;
}



}
23 changes: 23 additions & 0 deletions sources/Point.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef POINT_H
#define POINT_H
#include <string>
namespace ariel
{
using namespace std;
class Point{
private:
double x;
double y;

public:
Point(double, double);
double distance(Point &Other);
string print();
friend Point moveTowards(Point &source, Point &destenation, double distance);
double getX();
double getY();
void setX(double);
void setY(double);
};
}
#endif
8 changes: 8 additions & 0 deletions sources/SmartTeam.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "SmartTeam.hpp"

namespace ariel
{
SmartTeam::SmartTeam(Character *leader) : Team(leader) {}
void SmartTeam::add(Character *member) {}
void SmartTeam::attack(Team *enemy) {}
}
Loading