|
 |
|
 |
05-15-2005, 08:31 AM
|
#1 (permalink)
|
|
Regular Contributor
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
|
How would one make a test maker?
Me and my big fat mouth! My roomie is having troubles taking tests, so I offered to make a test program so that she could bone up on her material. I know how to hardcode such a beast, but that wouldn't help either of us in the respect that it would not be a very flexible program.
How would one go about : user can add, delete, modify the questions and subject. I'm sure there is more I haven't even thought about, but perhaps this will give me a start.
By the way, she don't know jack about computers. She still doesn't understand why her credit card won't work in the floppy drive.

|
|
|
05-15-2005, 08:48 AM
|
#2 (permalink)
|
|
[code][/code] enforcer
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
|
Why not learn the ways of std::vector? Then you can add, delete and modify whatever you want.
__________________
|
|
|
05-15-2005, 08:49 AM
|
#3 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
|
hardcode all the routines, but let it read/store the test information in a textfile, something like this:
Quote:
question 1
answer 1
question 2
answer 2
...
|
Make the program in C++, using string and the <vector> class perhaps with a class like:
Code:
class test {
private:
string question;
string answer;
void test();
void test(string q);
public:
void test(string q, string a)
{
question = q;
answer = a;
};
string get_question(void)
{
return question;
};
string get_answer(void)
{
return answer;
};
}
And then in the program use it something like this:
Code:
int main()
{
ifstream file("my_test.txt");
vector <test> my_test;
string read_question, read_answer;
while(!file.eof())
{
if(!file.getline(read_question, '\n'))
{
cout << "Error reding question from file" << endl;
return -1;
}
if(!file.getline(read_answer, '\n'))
{
cout << "Error reding answer from file" << endl;
return -1;
}
test temp_test(read_question, read_answer);
my_test.push_back(temp_test);
}
file.close();
/* do what ever loops you want with the my_test vector */
}
|
|
|
05-15-2005, 09:00 AM
|
#4 (permalink)
|
|
Regular Contributor
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
|
Valmont, what is std::vector? I don't think I've run across that one yet.
Redhead, that file access is what I'd like to learn. But how would I separate her subjects? I know she needs one for biochemestry and one for immunology (I think I spelled that right). Or is it possible to make a subject maker?
Thanks ya'll!
|
|
|
05-15-2005, 09:04 AM
|
#5 (permalink)
|
|
Regular Contributor
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
|
Gah! I forgot this earlier. What is the addy for DevC++? I'm on my emergency computer since lightening nailed my main one. I don't have ANY programming tools or tutorials on this one.
|
|
|
05-15-2005, 09:23 AM
|
#6 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
|
Quote:
|
Redhead, that file access is what I'd like to learn. But how would I separate her subjects?
|
then keep teh subjects in seperate files, and have it like:
Code:
int main(int argc, char** argv)
{
if(argc != 2)
{
cout << "Usage: " << argv[0] << " <file_name>" << endl;
return -1;
}
ifstream file(argv[1]);
if(!file.is_good())
{
cout << "Error opening file: " << argv[1] << endl;
return -1;
}
vector <test> my_test;
string read_question, read_answer;
while(!file.eof())
{
.....
|
|
|
05-15-2005, 11:56 AM
|
#7 (permalink)
|
|
Regular Contributor
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
|
Alrighty, er... What header file do I need to include to access the file operations? I never got that advanced in the books I bought. Pointers and arrays kept kicking my tail.
|
|
|
05-15-2005, 11:59 AM
|
#8 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
|
Code:
#include <iostream>
#include <ifstream>
#include <string>
#include <vector>
using namespace std;
|
|
|
05-15-2005, 12:14 PM
|
#9 (permalink)
|
|
Regular Contributor
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
|
Thanks! Hey, you know of any links or something that may help my understanding of this? I can read the code, but I don't understand the usage per se.
|
|
|
05-15-2005, 01:17 PM
|
#10 (permalink)
|
|
Regular Contributor
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
|
I know I've been outta the programming loop for about a year, but I can't even get my clear screen portion of the program to work. How annoying.
This is what I have so far.
Code:
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#define VIDEO 0x10 //video interrupt
#define COLS 80 //screen width
#define ROWS 25 //screen rows
void cls(void);
void locate(int col,int row);
int main()
{
cls();
printf ("TestMaker v1.0");
return 0;
}
void cls(void)
{
union REGS regs;
regs.h.ah=0x06; //func 6, scroll window
regs.h.al=0x00; //clear screen
regs.h.bh=0x07; //make screen "blank"
regs.h.ch=0x00; //upper left row
regs.h.cl=0x00; //upper left column
regs.h.dh=ROWS-1; //lower right row
regs.h.dl=COLS-1; //lower right column
int86(VIDEO,®s,®s);
locate(0,0); //home the cursor
}
void locate(int col,int row)
{
union REGS regs;
regs.h.ah=0x02; //vid func 2, move cursor
regs.h.bh=0x00; //video screen (always 0)
regs.h.dh=row; //cursor row position
regs.h.dl=col; //cursor column position
int86(VIDEO,®s,®s);
}
|
|
|
05-15-2005, 01:18 PM
|
#11 (permalink)
|
|
Regular Contributor
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
|
Aw hell. I just noticed my oops. I forgot to include the "}" at the very end. Grrr! Well, if anyone has a better suggestion for clearing screens no matter the platform, lemme know please.

Last edited by cheawick; 05-15-2005 at 01:20 PM.
Reason: trying not to keep posting too much
|
|
|
05-15-2005, 01:24 PM
|
#12 (permalink)
|
|
Regular Contributor
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
|
Blast it all!!! The bracket is there, it just didn't copy over. I'll keep plugging away as best as I can, but any advice would be appreciated.
|
|
|
05-15-2005, 04:40 PM
|
#13 (permalink)
|
|
Regular Contributor
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
|
I think I may be mixing up C and C++ again. remove the remarks and the program don't run at all.
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <fstream.h>
/*
#define VIDEO 0x10 //video interrupt
#define COLS 80 //screen width
#define ROWS 25 //screen rows
*/
//void cls(void);
//void locate(int col,int row);
int main()
{
int x=0;
//cls();
printf ("TestMaker v1.0\n");
printf ("05/15/2005\n");
printf ("\n\n\n\n");
printf ("MAIN MENU:\n\n");
printf ("A) TAKE A TEST\n");
printf ("B) FLASH CARD Q&A\n");
printf ("C) EDIT MATERIAL MENU\n");
printf ("D) MATERIAL OPTIONS\n");
//textcolor(6);
//textbackground(0);
cprintf ("\nQ) QUIT (EXIT PROGRAM)\n");
getchar(x);
return 0;
}
/*
void cls(void)
{
union REGS regs;
regs.h.ah=0x06; //func 6, scroll window
regs.h.al=0x00; //clear screen
regs.h.bh=0x07; //make screen "blank"
regs.h.ch=0x00; //upper left row
regs.h.cl=0x00; //upper left column
regs.h.dh=ROWS-1; //lower right row
regs.h.dl=COLS-1; //lower right column
int86(VIDEO,®s,®s);
locate(0,0); //home the cursor
}
void locate(int col,int row)
{
union REGS regs;
regs.h.ah=0x02; //vid func 2, move cursor
regs.h.bh=0x00; //video screen (always 0)
regs.h.dh=row; //cursor row position
regs.h.dl=col; //cursor column position
int86(VIDEO,®s,®s);
}
*/
|
|
|
05-16-2005, 12:08 AM
|
#14 (permalink)
|
|
[code][/code] enforcer
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
|
Get the engine up and running before coding anything else. You got the order totally wrong.
__________________
|
|
|
05-16-2005, 03:12 PM
|
#15 (permalink)
|
|
Regular Contributor
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
|
Sorry Valmont, what order have I gotten wrong? If you are perhaps referring to the clear screen, it is a snippet program I have used for a number of years- hence my confusion as to why the heck it is not working. <Sigh> Too bad programs are not like wine, which gets better over time, code simply becomes obsolete.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 07:51 AM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|