mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 05:14:00 +02:00
fix applogic
This commit is contained in:
parent
3d8cbd98b4
commit
da1423ee1c
4 changed files with 60 additions and 44 deletions
2
Makefile
2
Makefile
|
@ -6,7 +6,7 @@ all: brmbar.c
|
|||
bcc -Md -W brmbar.c -o brmbar.com
|
||||
|
||||
clean:
|
||||
rm -f brmbar.com
|
||||
rm -f brmbar.com brmbar
|
||||
|
||||
dos:
|
||||
dosbox brmbar.com
|
||||
|
|
76
brmbar.c
76
brmbar.c
|
@ -19,6 +19,7 @@ char people[PEOPLE_MAXCOUNT][PERSON_MAXLEN];
|
|||
|
||||
int items_count;
|
||||
int people_count;
|
||||
int last_item = -1;
|
||||
|
||||
char buf[BUFSIZE];
|
||||
|
||||
|
@ -86,61 +87,52 @@ void fill_people()
|
|||
fclose(f);
|
||||
}
|
||||
|
||||
int read_item() {
|
||||
int i;
|
||||
for (;;) {
|
||||
printf("i> ");
|
||||
if (fgets(buf, BUFSIZE, stdin)) {
|
||||
void read_input()
|
||||
{
|
||||
int i, balance;
|
||||
printf("> ");
|
||||
if (!fgets(buf, BUFSIZE, stdin)) return;
|
||||
|
||||
// scan items
|
||||
for (i = 0; i < items_count; ++i) {
|
||||
if (!strncmp( buf, items[i].ean, strlen(items[i].ean) )) {
|
||||
if (!strncmp(buf, items[i].ean, strlen(items[i].ean))) {
|
||||
if (items[i].price) {
|
||||
printf("Item: %s (%d Kc)\n\n", items[i].name, items[i].price);
|
||||
last_item = i;
|
||||
printf("\n%s %d Kc\n\n", items[i].name, items[i].price);
|
||||
} else {
|
||||
printf("Item: %s\n\n", items[i].name);
|
||||
last_item = -1;
|
||||
printf("\n%s\n\n", items[i].name);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
printf("Unknown item: %s\n", buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int read_person() {
|
||||
int i;
|
||||
for (;;) {
|
||||
printf("p> ");
|
||||
if (fgets(buf, BUFSIZE, stdin)) {
|
||||
for (i = 0; i < people_count; ++i) {
|
||||
if (!strncmp( buf, people[i], strlen(people[i]) )) {
|
||||
printf("Person: %s\n\n", people[i]);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
printf("Unknown person %s\n", buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void do_action(i, p) int i; int p; {
|
||||
// TODO: perform action - person P selected item I
|
||||
if (!strcmp("BACK", people[p])) {
|
||||
printf("Going back ...\n\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// scan people
|
||||
for (i = 0; i < people_count; ++i) {
|
||||
if (!strncmp( buf, people[i], strlen(people[i]) )) {
|
||||
printf("\nMember %s ", people[i]);
|
||||
if (last_item == -1) {
|
||||
balance = modify_credit(people[i], 0);
|
||||
printf("has %d Kc.\n\n", balance);
|
||||
} else {
|
||||
balance = modify_credit(people[i], items[last_item].price);
|
||||
printf("has ordered %s for %d Kc and now has %d Kc.\n\n", items[last_item].name, items[last_item].price, balance);
|
||||
last_item = -1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
printf("\nUnknown code %s\n", buf);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int i, p;
|
||||
fill_items();
|
||||
fill_people();
|
||||
for (;;) {
|
||||
i = read_item();
|
||||
p = read_person();
|
||||
do_action(i, p);
|
||||
read_input();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@ cred100 Credit 100
|
|||
cred200 Credit 200
|
||||
cred500 Credit 500
|
||||
cred1000 Credit 1000
|
||||
status Status 0
|
||||
RESET RESET 0
|
||||
4029764001807 Club Mate 0.5L -35
|
||||
4029764001821 Club Mate 0.33L -25
|
||||
|
|
26
people.txt
26
people.txt
|
@ -1,6 +1,30 @@
|
|||
abyssal
|
||||
alexka
|
||||
axtheb
|
||||
b00lean
|
||||
biiter
|
||||
blami
|
||||
chido
|
||||
czestmyr
|
||||
fissie
|
||||
harvie
|
||||
jenda
|
||||
joe
|
||||
johny
|
||||
kubicekh
|
||||
kxt
|
||||
lui
|
||||
nephirus
|
||||
niekt0
|
||||
pasky
|
||||
pborky
|
||||
prusajr
|
||||
rainbof
|
||||
ruza
|
||||
sargon
|
||||
stick
|
||||
swez
|
||||
tma
|
||||
tomsuch
|
||||
BACK
|
||||
tutchek
|
||||
zombie
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue