09-06-2003, 08:46 PM
hmmm... sounds quite a bit like a project i had to do when i did cs20. i won't help you code-wise, but tell you some other stuff.
1. now, first you should do everything with arrays because it sounds like you are going to book multiple flights. for example...
dim array(6)
can hold potentially the same amount of information as
array0 = 2
array1 = 23
array2 = 344
array3 = 32
array4 = 56
array5 = 76
array6 = 3
you could do this instead:
array(2) = 344
'code
'code
it will make things easier in one way: you will be working with alot less variables, so you can keep track of your program easier.
2. Subs
Sub is short for subroutine. to access one, click on edit, then create new sub... then name it. a sub contains code that can be executed as many times as you want. so all of your code for creating a ticket is in this subroutine: "bookticker" for cancelling a ticket: "cancelticket" for changing dates: "changeticket" so if you never used subroutines, your code would look like this:
10 CLS
20 PRINT "1:Book A Ticket"
30 PRINT "2:Cancel A Ticket"
40 PRINT "3:Change Date"
50 PRINT "4:Exit"
60 INPUT "Your Option?"; O
70 IF O = 1 THEN GOSUB 1000
80 IF O = 2 THEN GOSUB 2000
90 IF 0 = 3 THEN GOSUB 3000
100 IF 0 = 4 THEN GOSUB 4000
if you did use subroutines, then you could do this instead:
10 CLS
20 PRINT "1:Book A Ticket"
30 PRINT "2:Cancel A Ticket"
40 PRINT "3:Change Date"
50 PRINT "4:Exit"
60 INPUT "Your Option?"; O
70 IF O = 1 THEN bookticket
80 IF O = 2 THEN cancelticket
90 IF 0 = 3 THEN changeticket
100 IF 0 = 4 THEN end
notice i got rid of "goto 4000" "goto 1000" or whatever? it's much neater if you use subs. plus, you can use code over and over again. so suppose you gotta do some math for all the subroutines that calculates everything. instead of writing in the same code over and over again, you can just type in the name of the sub, and it will repeat what code you need!
3. creating a ticket
you'll need several arrays: one that holds the date, one that holds the destination, one holds the area. several will be used for the math (since you didn't tell us the math, i c an't help you too much there). you input the data into the variables, then, and calculate the math for the price.
4. deleting a ticket:
simple. you simply REDIM the variables. unless you're using arrays. then you simply turn all the correct variables into 0.
5. changing a ticket:
easy enough. just ask the person what date instead to use instead and dump the data into the variable that holds the date.
1. now, first you should do everything with arrays because it sounds like you are going to book multiple flights. for example...
dim array(6)
can hold potentially the same amount of information as
array0 = 2
array1 = 23
array2 = 344
array3 = 32
array4 = 56
array5 = 76
array6 = 3
you could do this instead:
array(2) = 344
'code
'code
it will make things easier in one way: you will be working with alot less variables, so you can keep track of your program easier.
2. Subs
Sub is short for subroutine. to access one, click on edit, then create new sub... then name it. a sub contains code that can be executed as many times as you want. so all of your code for creating a ticket is in this subroutine: "bookticker" for cancelling a ticket: "cancelticket" for changing dates: "changeticket" so if you never used subroutines, your code would look like this:
10 CLS
20 PRINT "1:Book A Ticket"
30 PRINT "2:Cancel A Ticket"
40 PRINT "3:Change Date"
50 PRINT "4:Exit"
60 INPUT "Your Option?"; O
70 IF O = 1 THEN GOSUB 1000
80 IF O = 2 THEN GOSUB 2000
90 IF 0 = 3 THEN GOSUB 3000
100 IF 0 = 4 THEN GOSUB 4000
if you did use subroutines, then you could do this instead:
10 CLS
20 PRINT "1:Book A Ticket"
30 PRINT "2:Cancel A Ticket"
40 PRINT "3:Change Date"
50 PRINT "4:Exit"
60 INPUT "Your Option?"; O
70 IF O = 1 THEN bookticket
80 IF O = 2 THEN cancelticket
90 IF 0 = 3 THEN changeticket
100 IF 0 = 4 THEN end
notice i got rid of "goto 4000" "goto 1000" or whatever? it's much neater if you use subs. plus, you can use code over and over again. so suppose you gotta do some math for all the subroutines that calculates everything. instead of writing in the same code over and over again, you can just type in the name of the sub, and it will repeat what code you need!
3. creating a ticket
you'll need several arrays: one that holds the date, one that holds the destination, one holds the area. several will be used for the math (since you didn't tell us the math, i c an't help you too much there). you input the data into the variables, then, and calculate the math for the price.
4. deleting a ticket:
simple. you simply REDIM the variables. unless you're using arrays. then you simply turn all the correct variables into 0.
5. changing a ticket:
easy enough. just ask the person what date instead to use instead and dump the data into the variable that holds the date.
Jumping Jahoolipers!