1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
// puzzle.cpp : main project file.
//Assigment 2 puzzle program by Ashish Chaudhary
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
class puzzle {
char nameOfPuzzles;
int sizeOfPuzzles;
int numOfPieces;
int missingPieces;
char ratings;
//these are a list of attritubes which are going to be used in the puzzle class
void setNameOfPuzzles (char anameOfPuzzles)
{
anameOfPuzzles = nameOfPuzzles;
}
char getNameOfPuzzles(char anameOfPuzzles)
{
return anameOfPuzzles;
}
void setSizeOfPuzzles (int thesizeOfPuzzles)
{
thesizeOfPuzzles = sizeOfPuzzles;
}
int getSizeOfPuzzles(int thesizeOfPuzzles)
{
return thesizeOfPuzzles;
}
void setNumOfPieces (int thenumOfPieces)
{
thenumOfPieces = numOfPieces;
}
int getNumOfPieces(int thenumOfPieces) // the above methods sets the attriubes so that they are easy to return
{
return thenumOfPieces;
}
void setMissingPieces(int theMissingPieces)
{
theMissingPieces = missingPieces;
}
void getMissingPieces(int theMissingPieces)
{
return theMissingPieces;
}
void viewRatings(int numOfPieces, char ratings)
{
if (numOfPieces >= 4)
{
rating = easy;
}
else if (numOfPieces <4&& numOfPieces >=8)
{
ratings = medium;
}
else if (numOfPieces < 8)
{
ratings = hard;
}
}
//the above method allows to create rating by using if statement to print out ratings
char addPuzzle(char aNameOfPuzzles, int theSizeOfPuzzles, int theNumOfPieces, char viewRatings, int theMissingPieces)
{
cout <<"enter information about the new puzzle";
cout <<" Name Of puzzle is:"; cin>> aNameOfPuzzles;
cout <<" Size Of puzzle is:"; cin>> theSizeOfPuzzles;
cout <<" Number Of pieces are:";cin>> theNumOfPieces;
cout <<" Number of missing pieces are:"; cin>>theMissingPieces;
cout <<" this puzzle is rated at:";cin>> viewRatings;
}
//creates a new jiasaw puzzle
return 0;
}
|
and the new class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
class puzzle (
protected:
char nameOfPuzzles, ratings;
int sizeOfPuzzles,numOfPieces, missingPieces;
public:
void set_values(int size, int pieces, int missing , char name, char rate)
(nameOfPuzzles = name; ratings = rate; sizeOfPuzzles = size; numOfPieces = pieces; missingPieces = missing;)
);
class puzzle 1: public puzzle {
public:
char newPuzzle()
{ return (name,rate,size,pieces,missing); }
};
int main () {
puzzle 1 puzz;
puzzle 1 puzz2;
puzz.set_values (ash puzz, meduim,9,4,4);
puzz2.set_values (jiasaw,easy,10,3,2);
cout << puzz.newPuzzle() << endl;
cout << puzz2.newPuzzle() << endl;
return 0;
}
|
full errors so far
------ Build started: Project: puzzle, Configuration: Debug Win32 ------
Compiling...
puzzle 1.cpp
.\puzzle 1.cpp(6) : error C2059: syntax error : 'protected'
.\puzzle 1.cpp(9) : error C2059: syntax error : 'public'
.\puzzle 1.cpp(11) : error C2065: 'name' : undeclared identifier
.\puzzle 1.cpp(11) : error C2143: syntax error : missing ')' before ';'
.\puzzle 1.cpp(11) : error C2072: 'set_values' : initialization of a function
.\puzzle 1.cpp(11) : fatal error C1903: unable to recover from previous error(s); stopping compilation
puzzle .cpp
.\puzzle .cpp(82) : error C2059: syntax error : 'return'
.\puzzle .cpp(82) : error C2238: unexpected token(s) preceding ';'
.\puzzle .cpp(86) : fatal error C1004: unexpected end-of-file found
interface class.cpp
.\interface class.cpp(25) : error C3861: 'add_puzzle': identifier not found
.\interface class.cpp(28) : error C3861: 'remove_puzzle': identifier not found
.\interface class.cpp(31) : error C3861: 'view_list_of_puzzles': identifier not found
.\interface class.cpp(34) : error C3861: 'view_by_ratings': identifier not found
.\interface class.cpp(37) : error C3861: 'view_number_of_missing_pieces': identifier not found
Generating Code...
Build log was saved at "file://c:\Documents and Settings\Nix\My Documents\Visual Studio 2008\Projects\puzzle\puzzle\Debug\BuildLog.htm"
puzzle - 14 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========