From eb191a70b482d0ca46de1d2b3366a4869546a73c Mon Sep 17 00:00:00 2001 From: cdez Date: Tue, 17 Sep 2024 07:58:31 -0700 Subject: [PATCH] Upload the test files for the examples folder. --- examples/constructors.cpp | 71 ++++++++++++++++++++++++++++++++++++++ examples/test | Bin 0 -> 16512 bytes examples/test.cpp | 25 ++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 examples/constructors.cpp create mode 100755 examples/test create mode 100644 examples/test.cpp diff --git a/examples/constructors.cpp b/examples/constructors.cpp new file mode 100644 index 0000000..e8b62cf --- /dev/null +++ b/examples/constructors.cpp @@ -0,0 +1,71 @@ +#include +#include +using namespace std; + +class DayOfYear +{ +private: + int month; + int day; + void testDate(); +public: + DayOfYear(int monthValue, int dayValue); + DayOfYear(int monthValue); + DayOfYear(); + + void input(); + void output(); + int getMonthNumber(); + int getDay(); +}; + +DayOfYear::DayOfYear(int monthValue, int dayValue) + : month(monthValue), day(dayValue) +{ + testDate(); +} + +DayOfYear::DayOfYear(int monthValue) + : month(monthValue), day(1) +{ + testDate(); +} + +DayOfYear::DayOfYear() + : month(1), day(1) +{} + +void DayOfYear::testDate() +{ + // + if((month < 1) || (month > 12)) + { + // + cout << "Invalid month.\n"; + } + if((day < 1) || (day > 31)) + { + // + cout << "Invalid day.\n"; + } +} + +void DayOfYear::output() +{ + string Months [] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + cout << "The month is " << Months[month-1] << " and the day is " << day; +} + +int main() +{ + DayOfYear date1(2, 21), date2(5), date3; + cout << "Initialized dates:" << endl; + date1.output(); cout << endl; + date2.output(); cout << endl; + date3.output(); cout << endl; + + date1 = DayOfYear(10, 31); + cout << "Date 1 reset to the following: " << endl; + date1.output(); cout << endl; + return 0; +} diff --git a/examples/test b/examples/test new file mode 100755 index 0000000000000000000000000000000000000000..f0fa5c184a7b07ffa0fbb5bcd709bcbd70349813 GIT binary patch literal 16512 zcmeHOeQX@X6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?82#jo?87$coWX{Vb3w!Lh>joK48L`ZH_)tVNC7;%-IFrL;o&B>tnpa@qe+M zy!R1heavF5D|wI@IQr+J=nV-h2O!zKgh%{QoEzt!v!&vaS*u z5=Ew7`_BM>8*5srzpVR(ZeTlJ{+?I=IOMeE7kk+k2$kkh885 eYqYtQ9-)*gy0pFVsA$ncSKAtNpVOT@toj#raBi6Z literal 0 HcmV?d00001 diff --git a/examples/test.cpp b/examples/test.cpp new file mode 100644 index 0000000..022cb02 --- /dev/null +++ b/examples/test.cpp @@ -0,0 +1,25 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +void printSize(int array[]) +{ + // + cout << sizeof(*array) << "\n"; +} + +int main() +{ + // + int array[] = {1, 2, 3, 4, 5, 6}; + cout << sizeof(array) << "\n"; + printSize(array); + return 0; +} \ No newline at end of file