/* * Pizza * ----- * This program is a pizza ordering program. * * It creates a window, several fields for typing in your name, * and several checkboxes and radio buttons for choosing what * you want on the pizza. Having filled in all the information, * a "place order" button will print out the order and exit the * the program. A "reset form" button empties the fields and * sets the program back to its inital state. */ #include field name, phone; textbox address; checkbox ham, mushrooms, olives, capsicum; radiobutton tomato, barbeque; void place_order(button b) { printf("Name = %s\n", gettext(name)); printf("Phone = %s\n", gettext(phone)); printf("Address = %s\n", gettext(address)); printf("Sauce:\n"); if (ischecked(tomato)) printf(" Tomato\n"); if (ischecked(barbeque)) printf(" Barbeque\n"); printf("Toppings:\n"); if (ischecked(ham)) printf(" Ham\n"); if (ischecked(mushrooms)) printf(" Mushrooms\n"); if (ischecked(olives)) printf(" Olives\n"); if (ischecked(capsicum)) printf(" Capsicum\n"); exitapp(); } void reset_form(button b) { settext(name, ""); settext(phone, ""); settext(address, ""); check(tomato); uncheck(barbeque); uncheck(ham); uncheck(mushrooms); uncheck(olives); uncheck(capsicum); show(name); } void main(void) { window w; rect r; w = newwindow("Pizza", rect(0,0,400,450), StandardWindow); setbackground(w, LightBlue); r = rect(10,10,120,30); newlabel("Name:", r, AlignRight); r.x += 130; name = newfield("", r); r.y += 35; r.x = 10; newlabel("Phone:", r, AlignRight); r.x += 130; phone = newfield("", r); r.y += 35; r.x = 10; newlabel("Address:", r, AlignRight); r.x += 130; r.height = 75; address = newtextbox("", r); r.y += 80; r.height = 25; r.x = 10; r.y += 10; newlabel("Sauce:", r, AlignRight); r.x += 130; tomato = newradiobutton("Tomato", r, NULL); r.y += 35; barbeque = newradiobutton("BBQ", r, NULL); r.y += 35; check(tomato); r.x = 10; r.y += 10; newlabel("Toppings:", r, AlignRight); r.x += 130; ham = newcheckbox("Ham", r, NULL); r.y += 35; mushrooms = newcheckbox("Mushrooms", r, NULL); r.y += 35; olives = newcheckbox("Olives", r, NULL); r.y += 35; capsicum = newcheckbox("Capsicum", r, NULL); r.y += 35; r.x = 50; r.y += 10; newbutton("Order Pizza", r, place_order); r.x += 130; newbutton("Reset Form", r, reset_form); show(w); mainloop(); }