first semester files
This commit is contained in:
BIN
1st-Semester-Fall-2021/CSNP/ClassesLesson/CSNP - Shortcut.lnk
Executable file
BIN
1st-Semester-Fall-2021/CSNP/ClassesLesson/CSNP - Shortcut.lnk
Executable file
Binary file not shown.
32
1st-Semester-Fall-2021/CSNP/ClassesLesson/Counter.cpp
Executable file
32
1st-Semester-Fall-2021/CSNP/ClassesLesson/Counter.cpp
Executable file
@@ -0,0 +1,32 @@
|
||||
#include "Counter.h"
|
||||
#include <climits>
|
||||
|
||||
// Counter::Counter()
|
||||
// {
|
||||
// maxValue = INT_MAX;
|
||||
// }
|
||||
|
||||
void Counter::setCount(int num)
|
||||
{
|
||||
value = num;
|
||||
}
|
||||
|
||||
void Counter::increment()
|
||||
{
|
||||
++value;
|
||||
}
|
||||
|
||||
void Counter::decrement()
|
||||
{
|
||||
--value;
|
||||
}
|
||||
|
||||
int Counter::getCount()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
int Counter::getMaxValue()
|
||||
{
|
||||
return maxValue;
|
||||
}
|
||||
13
1st-Semester-Fall-2021/CSNP/ClassesLesson/Counter.h
Executable file
13
1st-Semester-Fall-2021/CSNP/ClassesLesson/Counter.h
Executable file
@@ -0,0 +1,13 @@
|
||||
#define COUNTER_H
|
||||
|
||||
class Counter
|
||||
{
|
||||
private:
|
||||
int value, maxValue;
|
||||
public:
|
||||
void setCount(int);
|
||||
void increment();
|
||||
void decrement();
|
||||
int getCount();
|
||||
int getMaxValue();
|
||||
};
|
||||
27
1st-Semester-Fall-2021/CSNP/ClassesLesson/main.cpp
Executable file
27
1st-Semester-Fall-2021/CSNP/ClassesLesson/main.cpp
Executable file
@@ -0,0 +1,27 @@
|
||||
#include <iostream>
|
||||
#include "Counter.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
Counter c = Counter();
|
||||
int num;
|
||||
|
||||
cout << "The current count is " << c.getCount() << endl; // show that we can get the count
|
||||
|
||||
cout << "Enter a new number for the count: "; // show that we can change the count
|
||||
cin >> num;
|
||||
c.setCount(num);
|
||||
cout << "The new count is " << c.getCount() << endl;
|
||||
|
||||
cout << "Incramenting the count..." << endl; // show that we can increment the count
|
||||
c.increment();
|
||||
cout << "The new count is " << c.getCount() << endl;
|
||||
|
||||
cout << "Decrementing the count..." << endl; // show that we can decrement the count
|
||||
c.decrement();
|
||||
cout << "The new count is " << c.getCount() << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user