Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Me And I Will Become Your Slave
#11
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.
Jumping Jahoolipers!
Reply
#12
barok..i seriously din understand what u just said..
its like im afraid of arrays, as if arrays were gonna eat me up someday..i just cant get it!!!

no alternatives ?

and uh..please explain the part of all the prices of tickets, i need max help in that!!!!
Reply
#13
we need more info. and we can only help you so much.
Jumping Jahoolipers!
Reply
#14
what info you want ??? go to my post in "Projects"..i put all the info there by mistake
Reply
#15
Ok, I see a list of cities now...

Afraid of arrays? :o

Again, you see, there is no information by which one can figure out the cost of a ticket.

No formula.
No relative values for each destination.
etcetcetc....
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#16
hmm ok i see what you want..


i thought over it a bit and realised that id have to make a table like so:

A B C D
A X 8 3 2
B 2 X 3 1
C 5 2 X 7
D 4 3 8 X

where ABCD are the cities and the numbers are the fares

i have the fares written on a piece of paper and it would be stupid to type all the 90 combos with prices in a post so im just giving examples..

anyways, with the above table, it is clear that i will have to use arrays...but i really dont know how!?
I know its sumthin like
DIM A(90)
LET A(1) = 2
LET A(2) = 5
Etc..

But then to get the table i would need to use a double dimension Array which is more confusing

Help!!!
Reply
#17
Ok..i spent loads of time and wrote down the whole table with the PRICES so you get an idea :
[it may look confusing but its the best i can do]
AMD BAN CHE COC COI DEL GOA KOL MAN MUM
AMD X 5000 6000 6500 6300 4780 6400 8000 7000 3200
BAN 5000 X 2795 3020 2255 8710 3785 9155 2555 4485
CHE 6000 2795 X 4240 3225 8960 5640 7825 5100 6215
COC 6500 3020 4240 X 2500 11975 4600 13300 6200 6215
COI 6300 2255 3225 2500 X 10715 6155 11370 4765 5620
DEL 4780 8710 8960 11975 10715 X 9100 6925 9200 6095
GOA 6400 3785 5640 4600 6155 9100 X 12600 3100 3005
KOL 8000 9155 7825 13300 11370 6925 12600 X 11200 8100
MAN 7000 2555 5100 6200 4765 9200 3100 11200 X 4280
MUM 3200 4485 6215 6215 5620 6095 3009 8100 4280 X
Reply
#18
If the rate is determined by distance, and you know the coordinates of each city, you can make yourself a formula instead of plugging in the numbers into a 2D array, like this:

Code:
DIM SHARED city.amount%: city.amount% = 10
DIM SHARED price.to.city%(1 TO city.amount%, 1 TO city.amount%)
DIM SHARED city.name$(1 TO 2, 1 to city.amount%) '(2) is (0 TO 2)
price.to.city%(1, 1) = 0
price.to.city%(1, 2) = 5000
price.to.city%(1, 3) = 6000
price.to.city%(1, 4) = 6500
price.to.city%(1, 5) = 6300
price.to.city%(1, 6) = 4780
price.to.city%(1, 7) = 6400
price.to.city%(1, 8) = 8000
price.to.city%(1, 9) = 7000
price.to.city%(1, 10) = 3200

'And do the same for the rest of the cities....

city.name$(1, 1) = "AMD"
city.name$(1, 2) = "BAN"
city.name$(1, 3) = "CHE"
city.name$(1, 4) = "COC"
city.name$(1, 5) = "COI"
city.name$(1, 6) = "DEL"
city.name$(1, 7) = "GOA"
city.name$(1, 8) = "KOL"
city.name$(1, 9) = "MAN"
city.name$(1, 10) = "MUM"
city.name$(2, 2) = "Bangladesh"

'And do the same for the rest of the cities....

'---------------------------------------

INPUT city.name.from$
INPUT city.name.to$
city.name.from$ = UCASE$(city.name.from$)
city.name.to$ = UCASE$(city.name.to$)

FOR i% = 1 to 2
FOR j% = 1 to city.amount%
temp$ = UCASE$(city.name$(i%, j%))
IF city.name.from$ = temp$ THEN city.from% = j%
IF city.name.to$ = temp$ THEN city.to% = j%
NEXT j%, i%

PRINT price.to.city%(city.from%, city.to%)
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#19
HELP!!!! i did not understand what you said Agamemnus..
Could you guide me line by line plz!!!





i thought about the array more and said, why dont i make each city, like 1,2,3,4 right..
so then the place ur goin from would be: 2
your destination would be : 3
So now i want the program to look up the array to slot 2,3 and print the value of that particular flight
Get it ?
Lol, i guess its the same thing youve done but i need it to be simplified as i cannot understand your code...!
Reply
#20
It's as simple as possible and does exactly what you just said. It matches up two different name sets (short and long form) with numbers... What parts don't you get.........?
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)