Embedded functions within HL class and removing from main

This commit is contained in:
Noah L. Schrick 2022-03-08 13:33:11 -06:00
parent b6c266add0
commit 1ea74d9021
7 changed files with 12 additions and 12 deletions

Binary file not shown.

Binary file not shown.

View File

@ -26,7 +26,7 @@ void HL::print_sol()
} }
//Divide and Conquer Strategy using recursive call to divide ls and merge using merge() //Divide and Conquer Strategy using recursive call to divide ls and merge using merge()
std::set<Line> HL::gen_sol(std::set<Line>& ls){ std::set<Line> HL::gen_sol(const std::set<Line>& ls){
HL inst = *this; HL inst = *this;
if (ls.size() > 2){ if (ls.size() > 2){
@ -129,6 +129,14 @@ std::set<Line> HL::construct_HWprob(){
lines.insert(newline); lines.insert(newline);
} }
std::cout << "Sorted Lines by slope:" << std::endl;
for(Line line : lines)
{
std::cout << "Line " << line.get_id() << " has slope " << line.get_slope()
<< " and a y-intercept of " << line.get_ycept() << std::endl;
}
return lines; return lines;
} }

View File

@ -10,7 +10,7 @@ class HL
HL(); HL();
void print_sol(); void print_sol();
std::set<Line> gen_sol(std::set<Line>& ls); std::set<Line> gen_sol(const std::set<Line>& ls);
std::set<Line> construct_HWprob(); std::set<Line> construct_HWprob();
std::set<Line> get_lines() const; std::set<Line> get_lines() const;

View File

@ -12,17 +12,9 @@ int main(int argc, char *argv[])
std::cout << "Constructing Problem..." << std::endl; std::cout << "Constructing Problem..." << std::endl;
HL inst = HL(); HL inst = HL();
std::set<Line> lines = inst.get_lines();
std::cout << "Sorted Lines by slope:" << std::endl;
for(Line line : lines)
{
std::cout << "Line " << line.get_id() << " has slope " << line.get_slope()
<< " and a y-intercept of " << line.get_ycept() << std::endl;
}
std::cout << "Generating Solution." << std::endl; std::cout << "Generating Solution." << std::endl;
inst.gen_sol(lines); inst.gen_sol(inst.get_lines());
std::cout << "Solution is: " << std::endl; std::cout << "Solution is: " << std::endl;
inst.print_sol(); inst.print_sol();
} }