Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
210CT-Coursework/Sceabble v0.2.1
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
159 lines (154 sloc)
3.85 KB
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
// Example program | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
class MyClass { // The class | |
public: // Access specifier | |
string Board[15][15]; | |
bool outofBounds = false; | |
int wordCount = 0; | |
int score = 0; | |
int wordscore = 0; | |
int x; | |
int y; | |
int turn = 1; | |
//string one[10] = {"a","e","i","o","u","l","n","s","t","r"}; | |
//string two[2] = {"d","g"}; | |
//string three[4] = {"b","c","m","p"}; | |
//string four[5] = {"f","h","v","w","y"}; | |
//string five[1] = {"k"}; | |
//string eight[2]{"j","x"}; | |
//string ten[2] = {"q","z"}; | |
//string points[26] = {"a","e","i","o","u","l","n","s","t","r","d","g","b","c","m","p","f","h","v","w","y","k","j","x","q","z"}; | |
string points = {"aeioulnstrdgbcmpfhvwykjxqz"}; | |
string word; | |
string direction; | |
void boardStart() { | |
for (int i = 0; i < 15; i++) { | |
for (int u = 0; u < 15; u++) { | |
Board[i][u] = { " " }; | |
} | |
} | |
Board[7][7] = { "*" }; | |
} | |
void boardBuild() { // Method function which builds the scrabble board | |
//Board[y][x] the first value is the y axis and 2nd value is the x axis | |
cout << " "; | |
for (int i = 0; i < 10; i++) { | |
cout << " " << i << " "; | |
} | |
for (int i = 1; i < 6; i++) { | |
cout << " " << 1 << " " << i - 1 << " "; | |
} | |
cout << endl; | |
for (int i = 0; i < 10; i++) { | |
cout << " " << i; | |
for (int u = 0; u < 15; u++) { | |
cout << " ["; | |
cout << Board[i][u]; | |
cout << "] "; | |
} | |
cout << endl << endl; | |
} | |
for (int i = 10; i < 15; i++) { | |
cout << i; | |
for (int u = 0; u < 15; u++) { | |
cout << " [" << Board[i][u] << "] "; | |
} | |
cout << endl << endl; | |
} | |
cout << endl; | |
} | |
void turnPlayer() { | |
cout << "Turn " << turn << endl; | |
cout << "Input the starting x and y coordinates for your word input." << endl; | |
cout << "x = "; | |
cin >> x; | |
cout << "y = "; | |
cin >> y; | |
cout << "r for right and d for down = "; | |
cin >> direction; | |
cout << "Input your word = "; | |
cin >> word; | |
cout << endl; | |
if (direction == "r") { | |
for (int u = 0; u < word.length(); u++) { | |
if (word.length() + x > 15) { | |
outofBounds = true; | |
} | |
else { | |
Board[y][u + x] = word[u]; | |
} | |
} | |
} | |
else if (direction == "d") { | |
for (int u = 0; u < word.length(); u++) { | |
if (word.length() + y > 15) { | |
outofBounds = true; | |
} | |
else { | |
Board[u + y][x] = word[u]; | |
} | |
} | |
} | |
if (turn == 1 && Board[7][7] == "*") { | |
boardStart(); | |
cout << "You did not input a word in the middle point" << endl; | |
turnPlayer(); | |
} | |
else { | |
boardBuild(); | |
if (outofBounds == false) { | |
turn += 1; | |
//for(int i = 0; i < word.length(); i++){ | |
//for | |
//} | |
for (int i = 0; i < 26; i++) { | |
for (int u = 0; u < word.length(); u++) { | |
if (points[i] == word[u] && i < 10) { | |
wordscore += 1; | |
} | |
else if (points[i] == word[u] && i < 12) { | |
wordscore += 2; | |
} | |
else if (points[i] == word[u] && i < 16) { | |
wordscore += 3; | |
} | |
else if (points[i] == word[u] && i < 21) { | |
wordscore += 4; | |
} | |
else if (points[i] == word[u] && i < 22) { | |
wordscore += 5; | |
} | |
else if (points[i] == word[u] && i < 24) { | |
wordscore += 8; | |
} | |
else if (points[i] == word[u] && i < 26) { | |
wordscore += 10; | |
} | |
} | |
} | |
//WORK on the TUPLE Array index for the word, word count and word basic score | |
wordCount += 1; | |
} | |
else { | |
cout << "Out of bounds please try again ! ! ! ! !" << endl << endl; | |
cout << "Out of bounds please try again ! ! ! ! !" << endl << endl; | |
cout << "Out of bounds please try again ! ! ! ! !" << endl << endl; | |
cout << "Out of bounds please try again ! ! ! ! !" << endl << endl; | |
cout << "Out of bounds please try again ! ! ! ! !" << endl << endl; | |
outofBounds == false; | |
} | |
cout << endl; | |
cout << "SCORE = " << score<<endl; | |
turnPlayer(); | |
} | |
} | |
}; | |
int main() | |
{ | |
MyClass myObj; | |
myObj.boardStart(); | |
myObj.boardBuild(); | |
myObj.turnPlayer(); | |
} |