Last active
August 29, 2015 14:06
-
-
Save aryelleification/6fad8b635f90bf551457 to your computer and use it in GitHub Desktop.
CountLT Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//CountLT.cpp | |
//Aryelle Young | |
//Sep 23 2014 | |
//Defines the CountLT class | |
#include "CountLT.h" | |
//Default Constructor | |
//takes a value from client code to use as initial bound | |
CountLT::CountLT(double bound) : the_bound(bound), count(0) | |
{ | |
} | |
//Destructor | |
CountLT::~CountLT() | |
{ | |
} | |
//Mutators | |
//Post: entry has been added to the collection tracked by CountLT. | |
void CountLT::put(double entry) | |
{ | |
if (entry < the_bound) | |
{ | |
count++; | |
} | |
} | |
//Accessors | |
//Post: the number of items less than the_bound has been returned. | |
int CountLT::get() | |
{ | |
return count; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//CountLT.h | |
//Aryelle Young | |
//Sep22 2014 | |
//An accumulator class whose objects | |
//count the number of entries in a | |
//sequence that are less than a given bound. | |
#ifndef _COUNTLT_H_ | |
#define _COUNTLT_H_ | |
class CountLT | |
{ | |
public: | |
//Default constructor | |
CountLT(double bound); | |
//Destructor | |
~CountLT(); | |
//Mutators | |
void put(double entry); | |
//Accessors | |
int get(); | |
private: | |
//Data members | |
int count; | |
double the_bound; | |
}; | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//CountLT_Driver.cpp | |
//Aryelle Young | |
// Sep 24 2014 | |
//Intended as a driver to test the functionality of class CountLT. | |
#include "CountLT.h" | |
#include <iostream> | |
#include <iomanip> | |
using namespace std; | |
int main() | |
{ | |
//Initial test of CountLT | |
CountLT testLessThan(13.13); | |
cout << "Count for new object testLessThan is " << testLessThan.get() << endl; | |
testLessThan.put(0.98); | |
testLessThan.put(-87.322); | |
testLessThan.put(14.1); | |
testLessThan.put(13.780); | |
testLessThan.put(51.00); | |
cout << endl; | |
cout << "After adding the quantities 0.98, -87.322, 14.1, 13.780, and 51.00 "; | |
cout << "to the collection tracked by the testLessThan object, the count is "; | |
cout << testLessThan.get() << endl; | |
testLessThan.put(13.109); | |
testLessThan.put(0); | |
testLessThan.put(7564.932); | |
cout << endl; | |
cout << "After adding the quantities 13.109, 0, and 7564.932 to the "; | |
cout << "collection tracked by testLessThan, the count is " << testLessThan.get(); | |
cout << endl; | |
cout << endl; | |
double sequence[] = { -54.88, 99.15, 49.821, 100.936, 1.234, 0.7562, -0.624, 8256.777, 30.826, 71 }; | |
double upper_bound = 55.00; | |
double lower_bound = 5.00; | |
cout << "Given the sequence: " << endl; | |
for (int i = 0; i < 10; i++) | |
{ | |
cout << setw(14) << sequence[i] << endl; | |
} | |
CountLT upper_tracker(upper_bound); | |
CountLT lower_tracker(lower_bound); | |
for (int i = 0; i < 10; i++) | |
{ | |
upper_tracker.put(sequence[i]); | |
lower_tracker.put(sequence[i]); | |
} | |
int countBetween = upper_tracker.get() - lower_tracker.get(); | |
cout << endl; | |
cout << "The number of entries between " << upper_bound; | |
cout << " and " << lower_bound << " is " << countBetween; | |
cout << "." << endl; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Undefined symbols for architecture x86_64: | |
"CountLT::get()", referenced from: | |
_main in CountLT_Driver-9c7b61.o | |
"CountLT::put(double)", referenced from: | |
_main in CountLT_Driver-9c7b61.o | |
"CountLT::CountLT(double)", referenced from: | |
_main in CountLT_Driver-9c7b61.o | |
"CountLT::~CountLT()", referenced from: | |
_main in CountLT_Driver-9c7b61.o | |
ld: symbol(s) not found for architecture x86_64 | |
clang: error: linker command failed with exit code 1 (use -v to see invocation) | |
[Finished in 0.3s with exit code 1] | |
[shell_cmd: g++ "/Users/ayoung92/Desktop/COSC_2030/CountLT_Driver.cpp" -o "/Users/ayoung92/Desktop/COSC_2030/CountLT_Driver"] | |
[dir: /Users/ayoung92/Desktop/COSC_2030] | |
[path: /usr/bin:/bin:/usr/sbin:/sbin] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works just fine for me, I created a fork with a Makefile in it. Give that a try with:
git clone https://gist.github.com/bemasher/ba32346393a1d112f63a CountLT cd CountLT make ./main