Commit 8d216392 authored by Brandon Toledo's avatar Brandon Toledo
Browse files

I finalized the Display class

parent ee5f1004
#include <iostream>
#include <vector>
#include <iomanip>
#include "Display.h"
using namespace std;
void Display::number (int value) {
if (value == 0) { middle();} //zero means that it is empty
else {cout << '|' << ' ' << setw(4) << value << ' ';}
}
void Display::showGame(const vector<vector<int>>& game) {
for (const vector<int>& colums: game ) {
for(int value: colums){
top();
}
cout << '+' << endl;
for(int value: colums){
middle();
}
cout << '|' << endl;
for(int value: colums){
number(value);
}
cout << '|' << endl;
for(int value: colums){
middle();
}
cout << '|' << endl;
}
for (const vector<int>& colums: game){
top();
}
cout << '+' << endl << endl << endl;
}
int main() {
vector<vector<int>> test {{1, 2, 0, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 15, 16, 19}};
Display box;
box.showGame(test);
return 0;
}
\ No newline at end of file
#include <iostream>
#include <vector>
using namespace std;
class Display {
public:
void showGame(const vector<vector<int>>& game);
private: //this functions is to print part of the box for 2014
void top() {cout << '+' << '-' << '-' << '-' << '-' << '-' << '-';}
void middle() {cout << '|' << ' ' << ' ' << ' ' << ' ' << ' ' << ' ';}
void number(int value);
};
\ No newline at end of file
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
class Display {
public:
void showGame(vector<vector<int>> game);
private:
void topOrB() {cout << '+' << '-' << '-' << '-' << '-' << '-' << '-';}
void middle() {cout << '|' << ' ' << ' ' << ' ' << ' ' << ' ' << ' ';}
void number(int value) {cout << '|' << ' ' << setw(4) << value << ' ';}
};
void Display:: showGame(vector<vector<int>> game) {
for (int i = 0; i )
}
int main() {
//vector<string> test(16);
//for (int i = 0; i < 16; i++) {test.at(i) = i;}
return 0;
}
\ No newline at end of file
#include <iostream>
#include <vector> // for 2D vector
using namespace std;
int main()
{
// Initializing 2D vector "vect" with
// values
vector<vector<int>> vect(4, vector<int>(4,0));
//vector<vector<int>> vect{ { 1, 2, 3 },
// { 4, 5, 6 },
// { 7, 8, 9 } };
// Displaying the 2D vector
for (vector<int> value: vect) {
for (int value1: value)
cout << value1 << " ";
cout << endl;
}
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment