From 5f79c51c74e6c4d098588c71fb332b94512e1ccb Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 19:29:49 -0500 Subject: [PATCH 01/15] Updated information files The information files have been updated to describe the current state of the repository. Repository owner information added to README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b13789..dd3cdf3 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ - +Name: Gregory Yentz +FSUID: gcy16 From d0cb75a1a3bfeb45e1722a67d553491526c7eabd Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 19:30:56 -0500 Subject: [PATCH 02/15] Updated status.txt file Status.txt now contains the output for the git status command. --- docs/status.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/status.txt b/docs/status.txt index 8b13789..adf688e 100644 --- a/docs/status.txt +++ b/docs/status.txt @@ -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 ..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: docs/status.txt + +no changes added to commit (use "git add" and/or "git commit -a") From 72b84da2f9a36c76729ae4debfff427f58d5f7d1 Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 19:33:04 -0500 Subject: [PATCH 03/15] Create answers.txt answers.txt is an empty file --- docs/answers.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/answers.txt diff --git a/docs/answers.txt b/docs/answers.txt new file mode 100644 index 0000000..e69de29 From a1469953eef049acd59a54e89e48a327effa0f09 Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 20:30:55 -0500 Subject: [PATCH 04/15] answer.txt completed answer.txt has all the answers to part 3 of the assignment --- docs/answers.txt | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/docs/answers.txt b/docs/answers.txt index e69de29..2a1b135 100644 --- a/docs/answers.txt +++ b/docs/answers.txt @@ -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. + From 0cf331d8ec780222753a8f235e33f652a7ea6ce9 Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 20:52:50 -0500 Subject: [PATCH 05/15] Create CrazyRandomSword and SimpleHammer files Some of the hitpoints and armor ignoring is incorrect, copied from commonspear --- CrazyRandomSword.cpp | 16 ++++++++++++++++ CrazyRandomSword.h | 31 +++++++++++++++++++++++++++++++ SimpleHammer.cpp | 16 ++++++++++++++++ SimpleHammer.h | 31 +++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 CrazyRandomSword.cpp create mode 100644 CrazyRandomSword.h create mode 100644 SimpleHammer.cpp create mode 100644 SimpleHammer.h diff --git a/CrazyRandomSword.cpp b/CrazyRandomSword.cpp new file mode 100644 index 0000000..78b73fe --- /dev/null +++ b/CrazyRandomSword.cpp @@ -0,0 +1,16 @@ +/* + * File: CrazyRandomSword.cpp + * Author: Gregory + * + * Created on Feb 3, 2019, 8:45 PM + */ + +#include "CrazyRandomSword.h" + +double CrazyRandomSword::hit(double armor) { + double damage = hitPoints - (armor * 0.8); + if (damage < 0) { + return 0; + } + return damage; +} diff --git a/CrazyRandomSword.h b/CrazyRandomSword.h new file mode 100644 index 0000000..002df0a --- /dev/null +++ b/CrazyRandomSword.h @@ -0,0 +1,31 @@ +/* + * File: CrazyRandomSword.h + * Author: Gregory + * + * Created on Feb 3, 2019, 8:45 PM + */ + +#include +#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", 40.0) { //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 */ + diff --git a/SimpleHammer.cpp b/SimpleHammer.cpp new file mode 100644 index 0000000..0088af7 --- /dev/null +++ b/SimpleHammer.cpp @@ -0,0 +1,16 @@ +/* + * File: SimpleHammer.cpp + * Author: Gregory + * + * Created on Feb 3, 2019, 8:45 PM + */ + +#include "SimpleHammer.h" + +double SimpleHammer::hit(double armor) { + double damage = hitPoints - (armor * 0.8); + if (damage < 0) { + return 0; + } + return damage; +} diff --git a/SimpleHammer.h b/SimpleHammer.h new file mode 100644 index 0000000..544e770 --- /dev/null +++ b/SimpleHammer.h @@ -0,0 +1,31 @@ +/* + * File: SimpleHammer.h + * Author: Gregory + * + * Created on Feb 3, 2019, 8:45 PM + */ + +#include +#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 */ + From d0ecd7b731bb6ba79481aa0a9a128f16d2ba1d9f Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 20:58:44 -0500 Subject: [PATCH 06/15] Update WeaponFactory.cpp Added the simplehammer and crazyrandomsword calls for getWeapon --- WeaponFactory.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/WeaponFactory.cpp b/WeaponFactory.cpp index 47ce803..adbb22a 100644 --- a/WeaponFactory.cpp +++ b/WeaponFactory.cpp @@ -28,5 +28,13 @@ 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(); + } + throw "Invalid weapon"; } \ No newline at end of file From fe95c0dce99c8f12c7d9dea56be22820478d5748 Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 21:02:07 -0500 Subject: [PATCH 07/15] Updated main.cpp main.cpp now creates the simplehammer and crazyrandomsword and simulates their use --- main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.cpp b/main.cpp index c1e7370..983ab6a 100644 --- a/main.cpp +++ b/main.cpp @@ -39,6 +39,14 @@ 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); + return 0; } From f0354215df2f03e0e5ee1f7d8c775ea3ac6f7a52 Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 21:16:53 -0500 Subject: [PATCH 08/15] Update CrazyRandomSword.h hitpoints CrazyRandomSword hitpoints is now a random number between 7 and 100 --- CrazyRandomSword.h | 3 ++- Weapon.cpp | 2 +- Weapon.h | 2 +- WeaponFactory.cpp | 2 +- WeaponFactory.h | 2 +- main.cpp | 4 ++-- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CrazyRandomSword.h b/CrazyRandomSword.h index 002df0a..fab03a6 100644 --- a/CrazyRandomSword.h +++ b/CrazyRandomSword.h @@ -6,6 +6,7 @@ */ #include +#include #include "Weapon.h" #ifndef CRAZYRANDOMSWORD_H @@ -18,7 +19,7 @@ class CrazyRandomSword : public Weapon { public: - CrazyRandomSword() : Weapon("Crazy random sword", 40.0) { //Calls Weapon(name, hitpoints) constructor with values Crazy random sword and random integer number between 7 and 100. + 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() {}; diff --git a/Weapon.cpp b/Weapon.cpp index 2c9cd3d..ef2f96d 100644 --- a/Weapon.cpp +++ b/Weapon.cpp @@ -1,7 +1,7 @@ /* * File: Weapon.cpp * Author: Javier - * + * Gregory */ #include "Weapon.h" diff --git a/Weapon.h b/Weapon.h index 199ec86..2f5c6f7 100644 --- a/Weapon.h +++ b/Weapon.h @@ -1,7 +1,7 @@ /* * File: Weapon.h * Author: Javier - * + * Gregory * Created on September 25, 2017, 3:21 PM */ diff --git a/WeaponFactory.cpp b/WeaponFactory.cpp index adbb22a..d87a660 100644 --- a/WeaponFactory.cpp +++ b/WeaponFactory.cpp @@ -1,7 +1,7 @@ /* * File: WeaponFactory.cpp * Author: Javier - * + * Gregory */ #include diff --git a/WeaponFactory.h b/WeaponFactory.h index 0d4b4c3..1921e30 100644 --- a/WeaponFactory.h +++ b/WeaponFactory.h @@ -1,7 +1,7 @@ /* * File: WeaponFactory.h * Author: Javier - * + * Gregory * Created on September 25, 2017, 3:25 PM */ #include "Weapon.h" diff --git a/main.cpp b/main.cpp index 983ab6a..258c04b 100644 --- a/main.cpp +++ b/main.cpp @@ -1,8 +1,8 @@ - /* * File: main.cpp * Author: Javier - * + * Gregory + * Created on September 25, 2017, 3:19 PM */ From ea8dfecd2ce2cf4c259656c0fb409c58b9cb95ce Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 21:22:38 -0500 Subject: [PATCH 09/15] Update SimpleHammer.cpp damage If armor is below 30, armor is ignored --- SimpleHammer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/SimpleHammer.cpp b/SimpleHammer.cpp index 0088af7..ca167cc 100644 --- a/SimpleHammer.cpp +++ b/SimpleHammer.cpp @@ -8,7 +8,13 @@ #include "SimpleHammer.h" double SimpleHammer::hit(double armor) { - double damage = hitPoints - (armor * 0.8); + double damage; + if(armor < 30.0){ + damage = hitPoints; + } + else{ + damage = hitPoints - armor; + } if (damage < 0) { return 0; } From 724cbbbb3a68ada8fbd71dbf2125381bfa01dc19 Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 21:32:25 -0500 Subject: [PATCH 10/15] Update CrazyRandomSword damage Damage now ignores a random amount of integer armor points, ranging from to 2 to a third of the armor the weapon hits --- CrazyRandomSword.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CrazyRandomSword.cpp b/CrazyRandomSword.cpp index 78b73fe..67a9e75 100644 --- a/CrazyRandomSword.cpp +++ b/CrazyRandomSword.cpp @@ -8,7 +8,7 @@ #include "CrazyRandomSword.h" double CrazyRandomSword::hit(double armor) { - double damage = hitPoints - (armor * 0.8); + double damage = hitPoints - (rand() % ((armor/3) - 2) + 2); if (damage < 0) { return 0; } From ee052e04f53e2c064b534de4a7deccdef131d225 Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 21:42:36 -0500 Subject: [PATCH 11/15] Create LightSaber.h and LightSaber.cpp LightSaber has either 1 or 100 hitpoints --- LightSaber.cpp | 16 ++++++++++++++++ LightSaber.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 LightSaber.cpp create mode 100644 LightSaber.h diff --git a/LightSaber.cpp b/LightSaber.cpp new file mode 100644 index 0000000..4a8811f --- /dev/null +++ b/LightSaber.cpp @@ -0,0 +1,16 @@ +/* + * File: CrazyRandomSword.cpp + * Author: Gregory + * + * Created on Feb 3, 2019, 8:45 PM + */ + +#include "LightSaber.h" + +double LightSaber::hit(double armor) { + double damage = hitPoints - (rand() % ((armor/3) - 2) + 2); + if (damage < 0) { + return 0; + } + return damage; +} diff --git a/LightSaber.h b/LightSaber.h new file mode 100644 index 0000000..eda1bce --- /dev/null +++ b/LightSaber.h @@ -0,0 +1,38 @@ +/* + * File: CrazyRandomSword.h + * Author: Gregory + * + * Created on Feb 3, 2019, 8:45 PM + */ + +#include +#include +#include "Weapon.h" + +#ifndef LIGHTSABER_H +#define LIGHTSABER_H + +/** + * Defines the behavior of a light saber (hitpoint = 50, ignores 20% of + * armor points) + */ +class LightSaber : public Weapon { +public: + + if(rand()%2==0){ + LightSaber() : Weapon("Lightsaber", 1.0) { //Calls Weapon(name, hitpoints) constructor with values lightsaber and randomly either 1 or 100. + } + } + if(rand()%2==1){ + LightSaber() : Weapon("Lightsaber", 100.0) { //Calls Weapon(name, hitpoints) constructor with values lightsaber and randomly either 1 or 100. + } + } + + virtual ~LightSaber() {}; + + virtual double hit(double armor); + +}; + +#endif /* LIGHTSABER_H */ + From 1153e644e6806dc714499a1b61d5ec929910776b Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 21:46:08 -0500 Subject: [PATCH 12/15] Update main and weaponfactory to include lightsaber Main now calls LightSaber and simulates its use. --- LightSaber.h | 2 +- WeaponFactory.cpp | 4 ++++ main.cpp | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/LightSaber.h b/LightSaber.h index eda1bce..0279291 100644 --- a/LightSaber.h +++ b/LightSaber.h @@ -13,7 +13,7 @@ #define LIGHTSABER_H /** - * Defines the behavior of a light saber (hitpoint = 50, ignores 20% of + * Defines the behavior of a light saber (hitpoint = 100 / 1, ignores 20% of * armor points) */ class LightSaber : public Weapon { diff --git a/WeaponFactory.cpp b/WeaponFactory.cpp index d87a660..88201e2 100644 --- a/WeaponFactory.cpp +++ b/WeaponFactory.cpp @@ -36,5 +36,9 @@ Weapon * WeaponFactory::getWeapon(std::string name) { return new CrazyRandomSword(); } + if (name.compare("lightsaber") == 0) { + return new LightSaber(); + } + throw "Invalid weapon"; } \ No newline at end of file diff --git a/main.cpp b/main.cpp index 258c04b..b4b64ac 100644 --- a/main.cpp +++ b/main.cpp @@ -47,6 +47,10 @@ int main(int argc, char** argv) { simulateWeapon(weapon, armor); delete(weapon); + weapon = WeaponFactory::getInstance()->getWeapon("lightsaber"); + simulateWeapon(weapon, armor); + delete(weapon); + return 0; } From c05fd3bf916b70163d51933e2a3c41736f1dcae3 Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 21:50:44 -0500 Subject: [PATCH 13/15] Update lightsaber damage Either they know the ways of the force and get minimal damage, or they don't and they get a ton of damage. --- LightSaber.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LightSaber.cpp b/LightSaber.cpp index 4a8811f..4156a2f 100644 --- a/LightSaber.cpp +++ b/LightSaber.cpp @@ -8,7 +8,7 @@ #include "LightSaber.h" double LightSaber::hit(double armor) { - double damage = hitPoints - (rand() % ((armor/3) - 2) + 2); + double damage = hitPoints - ((rand()%2)*50); //either they know or do not know that ways of the force if (damage < 0) { return 0; } From b83f4fe8ed7bf16f18d0bffbc5b7fb323806a100 Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 21:53:05 -0500 Subject: [PATCH 14/15] Update WeaponFactory Weaponfactory now includes the three new weapons in the include"" header --- WeaponFactory.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WeaponFactory.cpp b/WeaponFactory.cpp index 88201e2..19a19d2 100644 --- a/WeaponFactory.cpp +++ b/WeaponFactory.cpp @@ -9,6 +9,9 @@ #include "WeaponFactory.h" #include "CommonSword.h" #include "CommonSpear.h" +#include "CrazyRandomSword.h" +#include "SimpleHammer.h" +#include "LightSaber.h" WeaponFactory* WeaponFactory::instance = NULL; From 1698134250f94b8e10682a8c1ff12ebb712bd244 Mon Sep 17 00:00:00 2001 From: Gregory Yentz Date: Sun, 3 Feb 2019 22:15:17 -0500 Subject: [PATCH 15/15] Update Lightsaber.h Lightsaber now simplifies the random number generation --- LightSaber.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/LightSaber.h b/LightSaber.h index 0279291..b8e7609 100644 --- a/LightSaber.h +++ b/LightSaber.h @@ -19,14 +19,8 @@ class LightSaber : public Weapon { public: - if(rand()%2==0){ - LightSaber() : Weapon("Lightsaber", 1.0) { //Calls Weapon(name, hitpoints) constructor with values lightsaber and randomly either 1 or 100. - } - } - if(rand()%2==1){ - LightSaber() : Weapon("Lightsaber", 100.0) { //Calls Weapon(name, hitpoints) constructor with values lightsaber and randomly either 1 or 100. - } - } + LightSaber() : Weapon("Lightsaber", ((rand()%2)*98)+1) { //Calls Weapon(name, hitpoints) constructor with values lightsaber and randomly either 1 or 100. + } virtual ~LightSaber() {};