Hey guys, thanks for viewing my problem,,
i am currently working on a program and i am trying to input a menu to run with a template i have i am having trouble looping the menu with the template the program is an X,Y plotter i have a template up and running but i just cant get the menu to function with the template some help will be greatley appreciated or if somone could teach me step's here it goes:
The template
Code:
#include <iostream>
#include <stdio.h>
#include <fstream>
using namespace std;
int row = 0; int col = 0;
char Array [21][75];
void Reset(){ // the initilize function call it like this when you need it Reset();
for (row = 0; row < 21; ++row){
for (col = 0; col < 75; ++col)
Array[row][col] = '-';
col = 0;
}
};
void Display(){ // Displays the graph call it like this when you need it Display();
for (row = 21; row > 0; --row){
for (col = 0; col < 75; ++col)
cout << Array[row][col];
col = 0;
cout << "\n";
}
}
void selectfile(){ // lets them select a file call it like this when you need it selectfile();
system("cls");
ifstream myfile;
int Selection;
// read a input from the user and put in either
// this myfile.open("circle.txt");
// or this myfile.open("square.txt");
while(!myfile.eof()){ // loops through the file and reads it into the graph
myfile >> col;
myfile >> row;
Array[row][col] = '*';
}
}
void readkeyboard(){ // loop this code until they enter -99 in your own way
// call this function when you need it like this readkeyboard();
cout << "\nPlease enter row: ";
cin >> row;
cout << "\nPlease enter column: ";
cin >> col;
Array[row][col] = '*';
}
void exit(){
ofstream myfile1, myfile2;
myfile1.open("XYCanvas_StudentID.txt"); // put your number in here
for (row = 21; row > 0; --row){
for (col = 0; col < 75; ++col)
myfile1 << Array[row][col];
col = 0;
myfile1 << "\n";
}
myfile1.close();
myfile1.clear();
myfile2.open("Prog2_StudentID.txt"); // and your number in here
myfile2 << "name and number"; // name and number
myfile2.close();
myfile2.clear();
}
void Scale(){
int Scaling;
cout << "Scaling figure? ";
cin >> Scaling;
for (row = 0; row < 21; ++row)
{
for (col = 0; col < 75; ++col){
if (Array[row][col] == '*'){
Array[row][col] = '-';
Array[row*Scaling][col*Scaling] = 'X';
}
}
col = 0;
}
for (row = 0; row < 21; ++row)
{
for (col = 0; col < 75; ++col){
if (Array[row][col] == 'X')
Array[row][col] = '*';
}
col = 0;
}
}
void Shift(){
int shift_up, shift_down;
cout << "\nhow much up? ";
cin >> shift_up;
cout << "\nhow much up? ";
cin >> shift_down;
for (row = 0; row < 21; ++row)
{
for (col = 0; col < 75; ++col){
if (Array[row][col] == '*'){
Array[row][col] = '-';
Array[row+shift_up][col+shift_down] = 'X';
}
}
col = 0;
}
for (row = 0; row < 21; ++row)
{
for (col = 0; col < 75; ++col){
if (Array[row][col] == 'X')
Array[row][col] = '*';
}
col = 0;
}
}
int main(){
// just a little test on the already complete functions
Reset();
Display();
system("pause");
// menus supposed 2 go here??!?
};
The menu looks like this
void showMenu()
{
cout<< "\t\tC++ XY plotter Menu\n\n";
cout<< "\t1. Display XY plot\n";
cout<< "\t2. Read input from file\n";
cout<< "\t3. Read input from keyboard\n";
cout<< "\t4. Clear XY canvas\n";
cout<< "\t5. Scale/Shift figure\n";
cout<< "\t6. Exit program\n";
cout<< "\t7. Credits\n";
cout<< " Enter your choice: ";
}
any chance of any c++ enthusiasts having a crack at this or helping out?
if the menu could function with the template this program will be running perfectly.
any help will be greatley appreciated!