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
16 changes: 16 additions & 0 deletions CrazyRandomSword.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* File: CrazyRandomSword.cpp
* Author: Gregory <gyentz@gmail.com>
*
* Created on Feb 3, 2019, 8:45 PM
*/

#include "CrazyRandomSword.h"

double CrazyRandomSword::hit(double armor) {
double damage = hitPoints - (rand() % ((armor/3) - 2) + 2);
if (damage < 0) {
return 0;
}
return damage;
}
32 changes: 32 additions & 0 deletions CrazyRandomSword.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* File: CrazyRandomSword.h
* Author: Gregory <gyentz@gmail.com>
*
* Created on Feb 3, 2019, 8:45 PM
*/

#include <string>
#include <cstdlib>
#include "Weapon.h"

#ifndef CRAZYRANDOMSWORD_H
#define CRAZYRANDOMSWORD_H

/**
* Defines the behavior of a common spear (hitpoint = 40, ignores 20% of
* armor points)
*/
class CrazyRandomSword : public Weapon {
public:

CrazyRandomSword() : Weapon("Crazy random sword", ((rand()%93)+7)) { //Calls Weapon(name, hitpoints) constructor with values Crazy random sword and random integer number between 7 and 100.
}

virtual ~CrazyRandomSword() {};

virtual double hit(double armor);

};

#endif /* CRAZYRANDOMSWORD_H */

16 changes: 16 additions & 0 deletions LightSaber.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* File: CrazyRandomSword.cpp
* Author: Gregory <gyentz@gmail.com>
*
* Created on Feb 3, 2019, 8:45 PM
*/

#include "LightSaber.h"

double LightSaber::hit(double armor) {
double damage = hitPoints - ((rand()%2)*50); //either they know or do not know that ways of the force
if (damage < 0) {
return 0;
}
return damage;
}
32 changes: 32 additions & 0 deletions LightSaber.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* File: CrazyRandomSword.h
* Author: Gregory <gyentz@gmail.com>
*
* Created on Feb 3, 2019, 8:45 PM
*/

#include <string>
#include <cstdlib>
#include "Weapon.h"

#ifndef LIGHTSABER_H
#define LIGHTSABER_H

/**
* Defines the behavior of a light saber (hitpoint = 100 / 1, ignores 20% of
* armor points)
*/
class LightSaber : public Weapon {
public:

LightSaber() : Weapon("Lightsaber", ((rand()%2)*98)+1) { //Calls Weapon(name, hitpoints) constructor with values lightsaber and randomly either 1 or 100.
}

virtual ~LightSaber() {};

virtual double hit(double armor);

};

#endif /* LIGHTSABER_H */

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

Name: Gregory Yentz
FSUID: gcy16
22 changes: 22 additions & 0 deletions SimpleHammer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* File: SimpleHammer.cpp
* Author: Gregory <gyentz@gmail.com>
*
* Created on Feb 3, 2019, 8:45 PM
*/

#include "SimpleHammer.h"

double SimpleHammer::hit(double armor) {
double damage;
if(armor < 30.0){
damage = hitPoints;
}
else{
damage = hitPoints - armor;
}
if (damage < 0) {
return 0;
}
return damage;
}
31 changes: 31 additions & 0 deletions SimpleHammer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* File: SimpleHammer.h
* Author: Gregory <gyentz@gmail.com>
*
* Created on Feb 3, 2019, 8:45 PM
*/

#include <string>
#include "Weapon.h"

#ifndef SIMPLEHAMMER_H
#define SIMPLEHAMMER_H

/**
* Defines the behavior of a common spear (hitpoint = 40, ignores 20% of
* armor points)
*/
class SimpleHammer : public Weapon {
public:

SimpleHammer() : Weapon("Simple hammer", 25.0) { //Calls Weapon(name, hitpoints) constructor with values Simple hammer and 25.0
}

virtual ~SimpleHammer() {};

virtual double hit(double armor);

};

#endif /* SIMPLEHAMMER_H */

2 changes: 1 addition & 1 deletion Weapon.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* File: Weapon.cpp
* Author: Javier <jrescobara@gmail.com>
*
* Gregory <gyentz@gmail.com>
*/

#include "Weapon.h"
Expand Down
2 changes: 1 addition & 1 deletion Weapon.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* File: Weapon.h
* Author: Javier <jrescobara@gmail.com>
*
* Gregory <gyentz@gmail.com>
* Created on September 25, 2017, 3:21 PM
*/

Expand Down
17 changes: 16 additions & 1 deletion WeaponFactory.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
/*
* File: WeaponFactory.cpp
* Author: Javier <jrescobara@gmail.com>
*
* Gregory <gyentz@gmail.com>
*/

#include <string>
#include <stddef.h>
#include "WeaponFactory.h"
#include "CommonSword.h"
#include "CommonSpear.h"
#include "CrazyRandomSword.h"
#include "SimpleHammer.h"
#include "LightSaber.h"

WeaponFactory* WeaponFactory::instance = NULL;

Expand All @@ -28,5 +31,17 @@ Weapon * WeaponFactory::getWeapon(std::string name) {
return new CommonSpear();
}

if (name.compare("hammer") == 0) {
return new SimpleHammer();
}

if (name.compare("crazysword") == 0) {
return new CrazyRandomSword();
}

if (name.compare("lightsaber") == 0) {
return new LightSaber();
}

throw "Invalid weapon";
}
2 changes: 1 addition & 1 deletion WeaponFactory.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* File: WeaponFactory.h
* Author: Javier <jrescobara@gmail.com>
*
* Gregory <gyentz@gmail.com>
* Created on September 25, 2017, 3:25 PM
*/
#include "Weapon.h"
Expand Down
45 changes: 45 additions & 0 deletions docs/answers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
a)
Enter passphrase for key '/home/yentz/.ssh/id_rsa':
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 956 bytes | 0 bytes/s, done.
Total 7 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 1 local object.
To git@github.com:gregoryYentz/Assignment1.git
3d373c9..d0cb75a master -> master

b)
5 commits, git log

c)
Thu Jan 10 16:45:38 2019, git log -p .gitignore

d)
Branches are used for feature development and to ensure that any changes that pushed don't affect the main branch unless allowed by the repo owner.

e)
git log shows all the commits to a repo and git status shows which files have and have not been added to the index but not yet committed.

f)
git log Weapon.h

g)
git log --oneline | grep PATTERN

h)
I)
Inheritance is where the properties of the parent is passed down to the child.

II)
Polymorphism is the ability to not specify the datatype used for a function.

III)
Encapsulation is where certain data is hidden to the programmer but is accessable to the object through functions.

i)
Integration manager workflow has the developers push to their own public repositories where the dictator lieutenants workflow has the developers push to the lieutenant repositories that are then checked and merged into the blessed repository

j)
With such a large team, it would be very easy for one developer to be working on an older version of the "blessed" repository, the lieutant repositories would make sure nothing is being broken.

10 changes: 10 additions & 0 deletions docs/status.txt
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: docs/status.txt

no changes added to commit (use "git add" and/or "git commit -a")
16 changes: 14 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

/*
* File: main.cpp
* Author: Javier <jrescobara@gmail.com>
*
* Gregory <gyentz@gmail.com>

* Created on September 25, 2017, 3:19 PM
*/

Expand Down Expand Up @@ -39,6 +39,18 @@ int main(int argc, char** argv) {
simulateWeapon(weapon, armor);
delete(weapon);

weapon = WeaponFactory::getInstance()->getWeapon("hammer");
simulateWeapon(weapon, armor);
delete(weapon);

weapon = WeaponFactory::getInstance()->getWeapon("crazysword");
simulateWeapon(weapon, armor);
delete(weapon);

weapon = WeaponFactory::getInstance()->getWeapon("lightsaber");
simulateWeapon(weapon, armor);
delete(weapon);

return 0;
}