From a651d2c8f793903906147856d599e4e34443eae5 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Sun, 28 Mar 2021 14:53:22 -0400 Subject: [PATCH] Update CPP class for week 10 --- cpp/10.6.2-operator-overloading/a.out | Bin 0 -> 17504 bytes cpp/10.6.2-operator-overloading/main.cpp | 60 ++++++++++++++++ cpp/10.7.1-lab-vending-machine/a.out | Bin 0 -> 17736 bytes .../BankAccount.cpp | 68 ++++++++++++++++++ cpp/10.8-lab-BankAccount-class/BankAccount.h | 29 ++++++++ cpp/10.8-lab-BankAccount-class/a.out | Bin 0 -> 20008 bytes cpp/10.8-lab-BankAccount-class/main.cpp | 21 ++++++ cpp/10.9-lab-calculator-class/Calculator.cpp | 18 +++++ cpp/10.9-lab-calculator-class/Calculator.cpp~ | 8 +++ cpp/10.9-lab-calculator-class/Calculator.h | 23 ++++++ cpp/10.9-lab-calculator-class/Calculator.h~ | 15 ++++ cpp/10.9-lab-calculator-class/a.out | Bin 0 -> 18320 bytes cpp/10.9-lab-calculator-class/main.cpp | 39 ++++++++++ 13 files changed, 281 insertions(+) create mode 100755 cpp/10.6.2-operator-overloading/a.out create mode 100644 cpp/10.6.2-operator-overloading/main.cpp create mode 100755 cpp/10.7.1-lab-vending-machine/a.out create mode 100644 cpp/10.8-lab-BankAccount-class/BankAccount.cpp create mode 100644 cpp/10.8-lab-BankAccount-class/BankAccount.h create mode 100755 cpp/10.8-lab-BankAccount-class/a.out create mode 100644 cpp/10.8-lab-BankAccount-class/main.cpp create mode 100644 cpp/10.9-lab-calculator-class/Calculator.cpp create mode 100644 cpp/10.9-lab-calculator-class/Calculator.cpp~ create mode 100644 cpp/10.9-lab-calculator-class/Calculator.h create mode 100644 cpp/10.9-lab-calculator-class/Calculator.h~ create mode 100755 cpp/10.9-lab-calculator-class/a.out create mode 100644 cpp/10.9-lab-calculator-class/main.cpp diff --git a/cpp/10.6.2-operator-overloading/a.out b/cpp/10.6.2-operator-overloading/a.out new file mode 100755 index 0000000000000000000000000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PBG3rT1WqoZW+;~k$MiW;p62wm57V_ck;)>~`n%frxMDgNW<*(4Fz80U6LfYU zndCa;gjrIzFtf^PEwiP9$&@j}F_BDWk6G02>9z)~(PJEae5;1xGt#cm5l&@!K4Au# z#g8>Pi^Lq!xmj(N5n%FJp-bUT?jF_y13>kJL5H{oM?9Pu5$;%A54#6rDfd7s0;!de z5JBEne}f(v6jC-6NDc{iXmXixr7l z?Nz|>H-y{gb#^8E4q!n!7G76Z8f-4FwH^46VU5c6yzc2C`zF%2+7m3gp@R3mY|rbX zhsnMLg9`=6h*fT%*Uwu3Lshotb<`9Ml-K>BA`7`=R^WXvuDRKs*IPBzVSYZr{bxO< zUk7_!!!yt8G7lLj)Dj;f?mxleKB!<<*`C*LBV@mW6uEu2=kY&C_N}CMVxb~yC&*xm zaAfh`)N21IU>FnjFZg#KZbh;1^BRN8=QA^(hKkwVMfNVTpI}9z1j9X*Q62+gw&(TD z0a8fOJRtR)9rHi5*z)-t@Lw`RCO@)siLsL+3z{X+X=WLum&v9mbwrBbZ2&zo> z{2cC7gJHpX^Vy#Q0nQz6pVwLZ{|Wg25a9gB!v45le*+AM$o9NGpQQx>>!B?cwrBbe zz|8i!b-YKai>(I9?b(j$`xbk?|KCdX^R>?o&p`!!asT%yiWCizy^@<)5*CKksN?<< z*s%Ykj*u*DkL!4IL0v3nYH32sC&^(C1s;EgFr++gzJ4qMjQcJPX;;}|R9>?Pxn0&> T3Kffr6um(YDC`yk3oHH$2`r<^ literal 0 HcmV?d00001 diff --git a/cpp/10.6.2-operator-overloading/main.cpp b/cpp/10.6.2-operator-overloading/main.cpp new file mode 100644 index 0000000..a36e2d6 --- /dev/null +++ b/cpp/10.6.2-operator-overloading/main.cpp @@ -0,0 +1,60 @@ +#include +using namespace std; + +class FamilyVacation { + public: + void SetNumDays(int dayCount); + void SetNumPeople(int peopleCount); + void Print() const; + FamilyVacation operator+(int moreDays); + private: + int numDays; + int numPeople; +}; + +void FamilyVacation::SetNumDays(int dayCount) { + numDays = dayCount; +} + +void FamilyVacation::SetNumPeople(int peopleCount) { + numPeople = peopleCount; +} + +// FIXME: Overload + operator so can write newVacation = oldVacation + 5, +// which adds 5 to numDays, while just copying numPeople. + +/* Your solution goes here */ +// Overload + operator for TimeHrMn +FamilyVacation FamilyVacation::operator+(int moreDays) { + FamilyVacation total; + + total.numDays = numDays + moreDays; + total.numPeople = numPeople; + + return total; +} + +void FamilyVacation::Print() const { + cout << "Days: " << numDays << ", People: " << numPeople << endl; +} + +int main() { + FamilyVacation firstVacation; + FamilyVacation secondVacation; + int userDays; + int userPeople; + + cin >> userDays; + cin >> userPeople; + + cout << "First vacation: "; + firstVacation.SetNumDays(userDays); + firstVacation.SetNumPeople(userPeople); + firstVacation.Print(); + + cout << "Second vacation: "; + secondVacation = firstVacation + 5; + secondVacation.Print(); + + return 0; +} diff --git a/cpp/10.7.1-lab-vending-machine/a.out b/cpp/10.7.1-lab-vending-machine/a.out new file mode 100755 index 0000000000000000000000000000000000000000..60584c03cac42fa5e931b39907c1cfd84c809f4e GIT binary patch literal 17736 zcmeGkZERcB^~O$HLyO}k=?E04fwHxfm?TX@_$YmL;`Di>ZI+~62P?0R?IsqEo!QSN zMcNh?*5QS+XhIB){m7(ks-|wLrfDmc)~0Jmr;Q(FVpI2}b*ya8=t@cptAOI2bKg16 z^Rt5xKlm}d8@+e#`Mmd@d)~)=z9(M}c6T|dsstB@xL+XFvs95J<1ECl*GrUW?P9S| z#7*Kxu@ETLa43?4(5NvSau^JTE|PNsM7{mQ-|tWWLtH^1Zjk3W$UQ`edUHjgssSe# z87M>HF>usdfK|eUM?nm5MS^8ylp)I%+w)2>A-sk>!@2$w-_#!ZX1dX!Pp>!h7_y$x zDUcyObO-94A-yxC$IwImV#xl)?&EQS_$M3+V2CRSM5jE@L6pVP^O_#T`VC&h5Gp0` z35f~8ko7(Tdf3koTiETr)ZTo4QKu4zJh zaC2WgoeB2FWi^$^1hLkqx5kpuL@3gyH#bLy!f8!UhvRxC6bS}L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E!>-h%@MZQ4>)`=_dfI?PT#F~+k{%JhWJ-_u z29sIeKsFBfqwy$_{DDxT9v&2u2eUpTe9=8guxCI$ZE$EMQi5o}gAfg)0@X$my70-H zj}P+gpe`NZOQ+<;=8Fx{g+CMpUB(Oz<03XRxDJNH!|@2TngUyJ^2r7aV=#%r2lt|3 zxWAO%PCqh+>vnj=z`K`Gc>TnA%DiqTwv^>M!dv0MwK41SI*ap>SE7)q@OulB+Mr_A z=k-{g40>6RpjBT5IzF4Yeg2-{g69qvyB^YSB{{1; zk;P`H;5#_$^E&WJ(r-uSLcuX&mD}g{ifuqcQP$`6;xu)Tzi)tuEM$&R@i5fz+XCzJ zy0V@+%->?N_Y$64PTH-n4{u5a|1{Lfo>+?Ewg!FfkAh*x@JpLz0 zKR|N4o;^hh(leRQG)Zx>-2lZi>oI)8qR;Dx?W8|n`)u$nsGu$G|Cpjk))46{miaTd zQbeBKfiw1>#ET5p4;3j!1!b|Ap`{7QKST!4kmK<=v=$B?H^&8jcjdlIMLIp#Zd5*H Y30Q8IWtT#wlK#>A3<;-2!Gena0lMR~O#lD@ literal 0 HcmV?d00001 diff --git a/cpp/10.8-lab-BankAccount-class/BankAccount.cpp b/cpp/10.8-lab-BankAccount-class/BankAccount.cpp new file mode 100644 index 0000000..a1af96b --- /dev/null +++ b/cpp/10.8-lab-BankAccount-class/BankAccount.cpp @@ -0,0 +1,68 @@ +#include +#include "BankAccount.h" +using namespace std; +// TODO: Define public member functions +string cust_name; +double checking; +double savings; + + + BankAccount::BankAccount(string newName, double amt1, double amt2){ + cust_name = newName; + checking = amt1; + savings = amt2; + } + + void BankAccount::SetName(string newName){ + cust_name = newName; + } + + string BankAccount::GetName(){ + return cust_name; + } + + void BankAccount::SetChecking(double amt){ + checking = amt; + } + + double BankAccount::GetChecking(){ + return checking; + } + void BankAccount::SetSavings(double amt){ + savings = amt; + } + + double BankAccount::GetSavings(){ + return savings; + } + + void BankAccount::DepositChecking(double amt){ + if (amt>0){ + checking+=amt; + } + } + + void BankAccount::DepositSavings(double amt){ + if (amt>0){ + savings+=amt; + } + } + + void BankAccount::WithdrawChecking(double amt){ + if (amt>0){ + checking-=amt; + } + } + + void BankAccount::WithdrawSavings(double amt){ + if (amt>0){ + savings-=amt; + } + } + + void BankAccount::TransferToSavings(double amt){ + if (amt>0){ + checking -= amt; + savings += amt; + } + } diff --git a/cpp/10.8-lab-BankAccount-class/BankAccount.h b/cpp/10.8-lab-BankAccount-class/BankAccount.h new file mode 100644 index 0000000..85fa85f --- /dev/null +++ b/cpp/10.8-lab-BankAccount-class/BankAccount.h @@ -0,0 +1,29 @@ +#ifndef BANKACCOUNTH +#define BANKACCOUNTH + +#include +using namespace std; + +class BankAccount { + public: + // TODO: Declare public member functions + BankAccount(string newName, double amt1, double amt2); + void SetName(string newName); + string GetName(); + void SetChecking(double amt); + double GetChecking(); + void SetSavings(double amt); + double GetSavings(); + void DepositChecking(double amt); + void DepositSavings(double amt); + void WithdrawChecking(double amt); + void WithdrawSavings(double amt); + void TransferToSavings(double amt); + private: + // TODO: Declare private data members + string cust_name; + double savings; + double checking; +}; + +#endif diff --git a/cpp/10.8-lab-BankAccount-class/a.out b/cpp/10.8-lab-BankAccount-class/a.out new file mode 100755 index 0000000000000000000000000000000000000000..95d0625615ab34f1b734b962649ed6282dff798e GIT binary patch literal 20008 zcmeHP4{#jSd4D>|wg6i?{{!2E`1oULN_^bevMnIMO4i9MEZM@c!6BIS`E;@_mhQy; zF|r#IQ^yP!;ou=|aG0i}p$yS zs}~muP0Sac6_Y`!!cUVNf>w=Tx5r{ItX6WBfTTC1_(L8I7~vWL@fmq6K<*(y(km2A zRTZ47P=;O$C%s8jRk-kKgaOwi$XqCaV90X$_Iws!_%y4c;18uyAsE{A$T!1_Eb-x+ zEIo$fYTWHS7}YN#lirBZ8&P@;y-JTE`;*Mj@0j8r^Ju^b*9eFvc`QJZrPBUJx|8Yw zA7KPF2b`)L&ye+QgC6zs(-wC7TGd`Tzi6ue3{~^ux}MnP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W_I3aZxElNNruGZB6yH{&RM>`x}-72hB2R`)+Rn?)XjQRGb9@9QiZ z*4>R|gX?H2+#8EPB?0R=_+^upd7K8qkDIh!+<4hL`?380WB9!S zH=rJy7!_BdhDV3I{xOdRtnmL*u98^cfX7!ySq99mZ+bMzH&usx5-S|s`Z`$j%)tHU zePH^(8C0IIfWYIHEO<v}J?q1n?^EB2=M^fv&%^y^Ifh#y zL+?@;=l$#lmHsX=f+1rp5<6>gvPdHi1mkMtW!2!-DV zwJZIDD&R<;blm!12aQD7zVK?mP_Pw6g`e9k%xa741he?r^?gd;r}Sz6&|Vao&5Qjm zectD7pKfW*R(@m~tk3vkE`8p=@1AE#@Owd)CtumiAQ0*z`(OApU?@I$%HKX=l2T-7FZH>EU2K%oOl`Z z8vNAhmVXby{|AZVjLmTS3~B$F_U>4p-&dSc8we~{PX9MxQ0%cjzt`aZGi5*j$p+iw zICvj48b9mv`;RfT5yf((ONI3rj)P{`7n(+5)(5cwLlP+*SdSt7i!!@D?_UiCES+-g zv&AV;CR^Np-d{VU^xMg}t!TD7RVltmM2Y9QtlyHSSQR#BhxypI$yNs~WJIkawEwsq pKOQ&71)ZMUcT2-Mnm1Z-i|hR5c3GBA^HTb2LYBmAmx2ow{|&FeFiHRb literal 0 HcmV?d00001 diff --git a/cpp/10.8-lab-BankAccount-class/main.cpp b/cpp/10.8-lab-BankAccount-class/main.cpp new file mode 100644 index 0000000..4b58060 --- /dev/null +++ b/cpp/10.8-lab-BankAccount-class/main.cpp @@ -0,0 +1,21 @@ +#include +#include +#include "BankAccount.h" +using namespace std; + +int main() { + BankAccount account("Mickey", 500.00, 1000.00); + account.SetChecking(500); + account.SetSavings(500); + account.WithdrawSavings(100); + account.WithdrawChecking(100); + account.TransferToSavings(300); + + cout << account.GetName() << endl; + cout << fixed << setprecision(2); + cout << account.GetChecking() << endl; + cout << account.GetSavings() << endl; + + return 0; +} + diff --git a/cpp/10.9-lab-calculator-class/Calculator.cpp b/cpp/10.9-lab-calculator-class/Calculator.cpp new file mode 100644 index 0000000..b74838a --- /dev/null +++ b/cpp/10.9-lab-calculator-class/Calculator.cpp @@ -0,0 +1,18 @@ +#include +#include "Calculator.h" +using namespace std; + +double value; +// TODO: Define default constructor +Calculator::Calculator(){ + value = 0; +} +// TODO: Define member functions - +// Add(), Subtract(), Multiply(), Divide(), Clear(), GetValue() + +void Calculator::Add(double n) { value += n; } +void Calculator::Subtract(double n) { value -= n; } +void Calculator::Multiply(double n) { value *= n; } +void Calculator::Divide(double n) { value /= n; } +void Calculator::Clear() { value = 0; } +double Calculator::GetValue(){ return value; } diff --git a/cpp/10.9-lab-calculator-class/Calculator.cpp~ b/cpp/10.9-lab-calculator-class/Calculator.cpp~ new file mode 100644 index 0000000..5f8bfd5 --- /dev/null +++ b/cpp/10.9-lab-calculator-class/Calculator.cpp~ @@ -0,0 +1,8 @@ +#include +#include "Calculator.h" +using namespace std; + +// TODO: Define default constructor + +// TODO: Define member functions - +// Add(), Subtract(), Multiply(), Divide(), Clear(), GetValue() diff --git a/cpp/10.9-lab-calculator-class/Calculator.h b/cpp/10.9-lab-calculator-class/Calculator.h new file mode 100644 index 0000000..adf377d --- /dev/null +++ b/cpp/10.9-lab-calculator-class/Calculator.h @@ -0,0 +1,23 @@ +#ifndef CALCULATORH +#define CALCULATORH + +class Calculator { + public: + // TODO: Declare default constructor + + // TODO: Declare member functions - + // Add(), Subtract(), Multiply(), Divide(), Clear(), GetValue() + Calculator(); + void Add(double n); + void Subtract(double n); + void Multiply(double n); + void Divide(double n); + void Clear(); + double GetValue(); + + private: + // TODO: Declare private data member - value + double value; +}; + +#endif diff --git a/cpp/10.9-lab-calculator-class/Calculator.h~ b/cpp/10.9-lab-calculator-class/Calculator.h~ new file mode 100644 index 0000000..e411c6f --- /dev/null +++ b/cpp/10.9-lab-calculator-class/Calculator.h~ @@ -0,0 +1,15 @@ +#ifndef CALCULATORH +#define CALCULATORH + +class Calculator { + public: + // TODO: Declare default constructor + + // TODO: Declare member functions - + // Add(), Subtract(), Multiply(), Divide(), Clear(), GetValue() + + private: + // TODO: Declare private data member - value +}; + +#endif diff --git a/cpp/10.9-lab-calculator-class/a.out b/cpp/10.9-lab-calculator-class/a.out new file mode 100755 index 0000000000000000000000000000000000000000..0408dfdcb9a046498827551b133dc629a2e56acf GIT binary patch literal 18320 zcmeHP4QyN2b-p6~qa-dxD^8*$ZOyd~Dz`Bs*|MWFNb@L(@>3u?nq@og66c8`DTym3 z3gn|J2Xm*uZB|ZpClp0t6fLH1Kw%UaU=&;Dq=QY*hV2ywrW)B`Y#62%X-73~syfc1 z2DZ8H+k3TIXuTmx>MVqx zE1(*pQ{02|N5x0P8sMuW4JQc=7aa3QR4{B*sPF=k-bu|r=`ny2ZV(V3mgh2L4+)Z9 zxfr^t;PP69G8BG=liq5oYP{4T-LdUjk0HyI+6#~}O2CkSVW)P6p;M1yli#Am^G_)~ zhNpDD{n9DOXupU|dJ9@_LF+N}vz~?=PjZ8f3z~kxV*n%EARv0=xeQ5`%D_+U7}Z+> zgb_4c@C}Ix!I1TS7kcF9Z(BI*dvtp%#l_J6Gvsl9ESVVI(eYR^wk4UE$WCpU>fEtq zM@KM|3T~DC-T+5vPVL;iPdxhg)f4{PKmO)}FU@~%+Yh@s-|O}Nn*1go$R5d1A$i@L ztowj}2nS7tyKp!Q>5=R@95iIq_q%c2gM(v2_INy~PJGf+aq{Cb+fdRWJDIPq_59B5 zn|EzEv95b__#gT~TCuEyq2?OgjiA+{_pKm5yMp}BSD=4;1^WIK>{E;bI4a90L8#?t z3iS2jK`|FHq)H3yQt7}!@`m5Qxm-Npll-({NTOfMPXQzOQx)<8^Cn}*qM!N{&6OR( zvPQ>K6IRBKq;1O**6-~eOr$g6Juz8LB{N~F4cZ;?iCD5PI%v1IN5>**%T7lUcBU^H z4(|bN+i)b4h+3(PosLJw`}SIU+pO^54zf3BZ;K`-q&2%Uk;+&Qjd%1-B{ zaH6RzuK`!c(-=dZH`#|0xb(bYOphz^sY-k*_U5nR67vX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pYl(r$}{|esOj7;%dSVImj2yOD+zCf ILIo=R1GY)-2LJ#7 literal 0 HcmV?d00001 diff --git a/cpp/10.9-lab-calculator-class/main.cpp b/cpp/10.9-lab-calculator-class/main.cpp new file mode 100644 index 0000000..90925b2 --- /dev/null +++ b/cpp/10.9-lab-calculator-class/main.cpp @@ -0,0 +1,39 @@ +#include +#include +#include "Calculator.h" +using namespace std; + +int main() { + Calculator calc; + double num1; + double num2; + + cin >> num1; + cin >> num2; + + cout << fixed << setprecision(1); + // 1. The initial value + cout << calc.GetValue() << endl; + + // 2. The value after adding num1 + calc.Add(num1); + cout << calc.GetValue() << endl; + + // 3. The value after multiplying by 3 + calc.Multiply(3); + cout << calc.GetValue() << endl; + + // 4. The value after subtracting num2 + calc.Subtract(num2); + cout << calc.GetValue() << endl; + + // 5. The value after dividing by 2 + calc.Divide(2); + cout << calc.GetValue() << endl; + + // 6. The value after calling the clear() method + calc.Clear(); + cout << calc.GetValue() << endl; + + return 0; +}