Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Standard C, C++

Reply
 
LinkBack Thread Tools Display Modes
Old 05-15-2005, 08:31 AM   #1 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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.
cheawick is offline   Reply With Quote
Old 05-15-2005, 08:48 AM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Why not learn the ways of std::vector? Then you can add, delete and modify whatever you want.
__________________
Valmont is offline   Reply With Quote
Old 05-15-2005, 08:49 AM   #3 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
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 */
}
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 05-15-2005, 09:00 AM   #4 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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!
cheawick is offline   Reply With Quote
Old 05-15-2005, 09:04 AM   #5 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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.
cheawick is offline   Reply With Quote
Old 05-15-2005, 09:23 AM   #6 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
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())
    {
       .....
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 05-15-2005, 11:56 AM   #7 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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.
cheawick is offline   Reply With Quote
Old 05-15-2005, 11:59 AM   #8 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Code:
#include <iostream>
#include <ifstream>
#include <string>
#include <vector>

using namespace std;
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 05-15-2005, 12:14 PM   #9 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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.
cheawick is offline   Reply With Quote
Old 05-15-2005, 01:17 PM   #10 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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,&regs,&regs);
    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,&regs,&regs);
}
cheawick is offline   Reply With Quote
Old 05-15-2005, 01:18 PM   #11 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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
cheawick is offline   Reply With Quote
Old 05-15-2005, 01:24 PM   #12 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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.
cheawick is offline   Reply With Quote
Old 05-15-2005, 04:40 PM   #13 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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,&regs,&regs);
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,&regs,&regs);
}
*/
cheawick is offline   Reply With Quote
Old 05-16-2005, 12:08 AM   #14 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Get the engine up and running before coding anything else. You got the order totally wrong.
__________________
Valmont is offline   Reply With Quote
Old 05-16-2005, 03:12 PM   #15 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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.
cheawick is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
java/jsp test question ideas sde Java 2 03-25-2005 07:38 PM
How to test for empty date from MySql call? Wysocki PHP 3 02-06-2005 02:17 PM
how to test PHP R0B PHP 3 10-27-2004 03:28 PM


All times are GMT -8. The time now is 07:51 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting