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
|
bcc -Md -W brmbar.c -o brmbar.com
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f brmbar.com
|
rm -f brmbar.com brmbar
|
||||||
|
|
||||||
dos:
|
dos:
|
||||||
dosbox brmbar.com
|
dosbox brmbar.com
|
||||||
|
|
74
brmbar.c
74
brmbar.c
|
@ -19,6 +19,7 @@ char people[PEOPLE_MAXCOUNT][PERSON_MAXLEN];
|
||||||
|
|
||||||
int items_count;
|
int items_count;
|
||||||
int people_count;
|
int people_count;
|
||||||
|
int last_item = -1;
|
||||||
|
|
||||||
char buf[BUFSIZE];
|
char buf[BUFSIZE];
|
||||||
|
|
||||||
|
@ -86,61 +87,52 @@ void fill_people()
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_item() {
|
void read_input()
|
||||||
int i;
|
{
|
||||||
for (;;) {
|
int i, balance;
|
||||||
printf("i> ");
|
printf("> ");
|
||||||
if (fgets(buf, BUFSIZE, stdin)) {
|
if (!fgets(buf, BUFSIZE, stdin)) return;
|
||||||
for (i = 0; i < items_count; ++i) {
|
|
||||||
if (!strncmp( buf, items[i].ean, strlen(items[i].ean) )) {
|
// scan items
|
||||||
if (items[i].price) {
|
for (i = 0; i < items_count; ++i) {
|
||||||
printf("Item: %s (%d Kc)\n\n", items[i].name, items[i].price);
|
if (!strncmp(buf, items[i].ean, strlen(items[i].ean))) {
|
||||||
} else {
|
if (items[i].price) {
|
||||||
printf("Item: %s\n\n", items[i].name);
|
last_item = i;
|
||||||
}
|
printf("\n%s %d Kc\n\n", items[i].name, items[i].price);
|
||||||
return i;
|
} else {
|
||||||
}
|
last_item = -1;
|
||||||
|
printf("\n%s\n\n", items[i].name);
|
||||||
}
|
}
|
||||||
printf("Unknown item: %s\n", buf);
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int read_person() {
|
// scan people
|
||||||
int i;
|
for (i = 0; i < people_count; ++i) {
|
||||||
for (;;) {
|
if (!strncmp( buf, people[i], strlen(people[i]) )) {
|
||||||
printf("p> ");
|
printf("\nMember %s ", people[i]);
|
||||||
if (fgets(buf, BUFSIZE, stdin)) {
|
if (last_item == -1) {
|
||||||
for (i = 0; i < people_count; ++i) {
|
balance = modify_credit(people[i], 0);
|
||||||
if (!strncmp( buf, people[i], strlen(people[i]) )) {
|
printf("has %d Kc.\n\n", balance);
|
||||||
printf("Person: %s\n\n", people[i]);
|
} else {
|
||||||
return i;
|
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;
|
||||||
}
|
}
|
||||||
printf("Unknown person %s\n", buf);
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// error
|
||||||
|
printf("\nUnknown code %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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int i, p;
|
|
||||||
fill_items();
|
fill_items();
|
||||||
fill_people();
|
fill_people();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
i = read_item();
|
read_input();
|
||||||
p = read_person();
|
|
||||||
do_action(i, p);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,6 @@ cred100 Credit 100
|
||||||
cred200 Credit 200
|
cred200 Credit 200
|
||||||
cred500 Credit 500
|
cred500 Credit 500
|
||||||
cred1000 Credit 1000
|
cred1000 Credit 1000
|
||||||
status Status 0
|
RESET RESET 0
|
||||||
4029764001807 Club Mate 0.5L -35
|
4029764001807 Club Mate 0.5L -35
|
||||||
4029764001821 Club Mate 0.33L -25
|
4029764001821 Club Mate 0.33L -25
|
||||||
|
|
26
people.txt
26
people.txt
|
@ -1,6 +1,30 @@
|
||||||
|
abyssal
|
||||||
|
alexka
|
||||||
|
axtheb
|
||||||
|
b00lean
|
||||||
biiter
|
biiter
|
||||||
|
blami
|
||||||
|
chido
|
||||||
czestmyr
|
czestmyr
|
||||||
|
fissie
|
||||||
|
harvie
|
||||||
|
jenda
|
||||||
|
joe
|
||||||
|
johny
|
||||||
|
kubicekh
|
||||||
|
kxt
|
||||||
|
lui
|
||||||
|
nephirus
|
||||||
niekt0
|
niekt0
|
||||||
|
pasky
|
||||||
|
pborky
|
||||||
|
prusajr
|
||||||
|
rainbof
|
||||||
|
ruza
|
||||||
|
sargon
|
||||||
stick
|
stick
|
||||||
|
swez
|
||||||
|
tma
|
||||||
tomsuch
|
tomsuch
|
||||||
BACK
|
tutchek
|
||||||
|
zombie
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue