Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Player p("");
- bool play = true;
- cout << "Iveskite varda" << endl;
- string name;
- cin >> name;
- p.set_name(name);
- while(play){
- try{
- cout << "Zaidimas pradedamas" << endl;
- cout << "Imituojamas kvadratelio spejimas" << endl;
- bool sq_color = true;
- int enter_num;
- enter_num = g.get_pattern_width();
- int row, row_elem;
- bool r = 0; // mem. square color, 0 or 1
- int r_count = 0;
- srand(time(0));
- for (int i = 0; i < g.get_pattern_height(); i++){ // i - row, j - row element
- for (int j = 0; j < g.get_pattern_width(); j++){
- r = rand() % 2;
- if ((r == 0) && (r_count == g.get_pattern_width())){
- g.add_mem_square(r, g.get_pattern_height(), i, j); // i - row
- }else if ((r == 0) && (r_count < g.get_pattern_width()) && (i == (g.get_pattern_height() - 1))){
- r = 1;
- ++r_count;
- g.add_mem_square(r, g.get_pattern_height(), i, j);
- }else if ((r == 0) && (i != (g.get_pattern_height() - 1))){
- g.add_mem_square(r, g.get_pattern_height(), i, j);
- }else if ((r == 1) && (r_count == g.get_pattern_width())){
- r = 0;
- g.add_mem_square(r, g.get_pattern_height(), i, j);
- }else if ((r == 1) && (r_count < g.get_pattern_width())){
- ++r_count;
- g.add_mem_square(r, g.get_pattern_height(), i, j);
- }
- }
- }
- for (int i = 0; i < g.get_pattern_height(); i++){ // i - row, j - row element
- for (int j = 0; j < g.get_pattern_width(); j++){
- cout << g.get_square_at(i, j) << endl;
- }
- cout << endl << "eileje yra elementu: " << g.get_squares_count(i) << endl;
- }
- while ((enter_num != 0) && sq_color){
- cout << "Iveskite kordinates" << endl;
- cin >> row;
- cin >> row_elem;
- sq_color = g.check_square_color(row, row_elem, &p);
- --enter_num;
- }
- if (p.get_points() == g.get_pattern_width() * 10){
- cout << "Sveikiname, jus perejote lygi. Jusu turimi taskai: " << p.get_points() << endl;
- }
- else{
- cout << "Pralaimejote. Jusu surinkti taskai: " << p.get_points() << endl;
- cout << "Spauskite 1, jei norite zaisti dar karta; 0 - jei norite iseiti is zaidimo" << endl;
- cin >> play;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement