Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

You may work in pairs for this assignment. Submit only one project per team; both partners will receive the same grade. Also, you can earn up to 40 points (out of 25) on this assignment!

Game rules:

1. To win, a player must get four pieces in a row (either horizontally, vertically, or diagonally).

2. Players cannot arbitrarily place pieces anywhere on the board. Instead, they choose a column to place the piece into, and the piece automatically drops into the lowest available position on that column.

3. The board is larger than a 3x3 grid (it should be fairly obvious why 3x3 wouldn't make sense for Connect Four). In this assignment you'll be designing your program in such a way that the board size is customizable.

A. The Assignment

Write a program that allows two players to play Connect Four against each other. Your program should start by allowing the user to specify the size of the game board (number of rows, number of columns). Once the game begins, players take turns entering which column they wish to drop a piece into. Your program should display a graphical (well, more like "graphical") representation of the board before each player's turn (this doesn't have to be pretty, just functional... although pretty is always a plus). The game should continue until either player wins the game, or until all spaces are filled with no winner (tie). Once the game ends, display an appropriate "Game Over" message and allow the user to indicate whether to play again.

Use a 2-D int array to keep track of the current state of the game board. Each position in the board has three possible states:

no piece, player 1's piece, or player 2's piece. You can use X's and O's or 0's and 1's to represent each player's pieces, but you're also welcome to pick something else.

There are no requirements on what methods you should write or how you organize your code. The most important thing is that it works correctly.

Error checking

Error Checking Implement error checking on all user inputs (but don't worry about data type mismatches) should repeatedly prompt for the input until the user enters a valid value. In particular: The minimum number of rows and columns in the board should be 4, and the maximum should be 10. (The number of rows does not necessarily have to match the number of columns, as long as both are within this allowable range.) When taking a turn, a player should not be able to specify a column that is outside the range of the board, or a column that is already full.

B. Code and Style Requirements

Use good coding style as discussed in class and your textbook. This includes: Judicious use of comments. There should be comments throughout your program explaining what your code is doing (but don't get too enthusiastic and comment obvious things like "this is a variable declaration"). Also be sure to place your name in the comment block at the top of your  program. Following programming conventions for variableNames/methodNames, ClassNames, CONSTANT_NAMES.

Giving your variables descriptive identifiers. Consistently indenting your code. This is for the benefit of yourself as well as the grader! Well-indented code is much easier to read.

Five points of your grade on this assignment will come from coding style. Remember that your code must successfully compile and run to receive any credit.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M9525808

Have any Question?


Related Questions in C/C++

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As