Commit d64a42e1 authored by Colin Hain's avatar Colin Hain
Browse files

The combos, toast, coleslaw, and sauce is implemented. The extra strips and...

The combos, toast, coleslaw, and sauce is implemented. The extra strips and drinks are not because it would be the same implementation.
parent 1f0ddda5
from kivy.app import App
from kivy.modules import inspector # For inspection.
from kivy.core.window import Window # For inspection.
from kivy.modules import inspector # For inspection.
from kivy.core.window import Window # For inspection.
from kivy.properties import NumericProperty, BooleanProperty
__app_package__ = 'edu.unl.cse.soft161.order'
__app__ = 'Order Meal'
......@@ -9,9 +10,126 @@ __flags__ = ['--bootstrap=sdl2', '--requirements=python2,kivy', '--orientation=l
class OrderApp(App):
total = NumericProperty(0)
sales_tax = NumericProperty(0)
subtotal = NumericProperty(0)
enable_toast_1 = BooleanProperty(True)
enable_toast_2 = BooleanProperty(True)
enable_toast_3 = BooleanProperty(True)
enable_coleslaw_1 = BooleanProperty(True)
enable_coleslaw_2 = BooleanProperty(True)
enable_coleslaw_3 = BooleanProperty(True)
enable_sauce_1 = BooleanProperty(True)
enable_sauce_2 = BooleanProperty(True)
enable_sauce_3 = BooleanProperty(True)
def build(self):
inspector.create_inspector(Window, self) # For inspection (press control-e to toggle).
inspector.create_inspector(Window, self) # For inspection (press control-e to toggle)
def disable_toast(self):
if self.root.ids.toast_1.active:
self.enable_toast_2 = False
self.enable_toast_3 = False
if self.total >= .01:
self.subtotal -= .49
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
elif self.root.ids.toast_2.active:
self.enable_toast_1 = False
self.enable_toast_3 = False
self.subtotal += .49
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
elif self.root.ids.toast_3.active:
self.enable_toast_1 = False
self.enable_toast_2 = False
self.subtotal += .49 * 2
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
def disable_coleslaw(self):
if self.root.ids.coleslaw_1.active:
self.enable_coleslaw_2 = False
self.enable_coleslaw_3 = False
if self.total >= .01:
self.subtotal -= .49
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
elif self.root.ids.coleslaw_2.active:
self.enable_coleslaw_1 = False
self.enable_coleslaw_3 = False
self.subtotal += .49
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
elif self.root.ids.coleslaw_3.active:
self.enable_coleslaw_1 = False
self.enable_coleslaw_2 = False
self.subtotal += .49 * 2
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
def disable_sauce(self):
if self.root.ids.sauce_1.active:
self.enable_sauce_2 = False
self.enable_sauce_3 = False
if self.total >= .01:
self.subtotal -= .29
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
elif self.root.ids.sauce_2.active:
self.enable_sauce_1 = False
self.enable_sauce_3 = False
self.subtotal += .29
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
elif self.root.ids.sauce_3.active:
self.enable_sauce_1 = False
self.enable_sauce_2 = False
self.subtotal += .29 * 2
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
def combo(self):
if self.root.ids.combo_1.state == 'down':
self.subtotal += 6.38
self.sales_tax += self.subtotal * .07
self.total += self.subtotal + self.sales_tax
elif self.root.ids.combo_2.state == 'down':
self.subtotal += 5.98
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
elif self.root.ids.combo_3.state == 'down':
self.subtotal += 6.98
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
elif self.root.ids.combo_4.state == 'down':
self.subtotal += 9.98
self.sales_tax = self.subtotal * .07
self.total = self.subtotal + self.sales_tax
def reset(self):
self.total = 0
self.sales_tax = 0
self.subtotal = 0
self.enable_toast_1 = True
self.enable_toast_2 = True
self.enable_toast_3 = True
self.root.ids.toast_1.active = False
self.root.ids.toast_2.active = False
self.root.ids.toast_3.active = False
self.enable_coleslaw_1 = True
self.enable_coleslaw_2 = True
self.enable_coleslaw_3 = True
self.root.ids.coleslaw_1.active = False
self.root.ids.coleslaw_2.active = False
self.root.ids.coleslaw_3.active = False
self.enable_sauce_1 = True
self.enable_sauce_2 = True
self.enable_sauce_3 = True
self.root.ids.sauce_1.active = False
self.root.ids.sauce_2.active = False
self.root.ids.sauce_3.active = False
if __name__ == '__main__':
app = OrderApp()
......
BoxLayout:
orientation: 'vertical'
Label:
text: '[Your meal-ordering GUI here]'
BoxLayout:
orientation: 'horizontal'
BoxLayout:
Button:
text: 'The Three Finger Combo'
id: combo_1
on_press: app.combo()
BoxLayout:
Button:
text: 'The Chicken Sandwich Combo'
id: combo_2
on_press: app.combo()
BoxLayout:
orientation: 'horizontal'
BoxLayout:
Button:
text: 'The Box Combo'
id: combo_3
on_press: app.combo()
BoxLayout:
Button:
text: 'The Caniac Combo'
id: combo_4
on_press: app.combo()
BoxLayout:
orientation: 'horizontal'
BoxLayout:
orientation: 'vertical'
Label:
text: 'Toast'
BoxLayout:
id: toast
orientation: 'horizontal'
Label:
text: 'No Toast'
font_size: 13.0
CheckBox:
id: toast_1
group: 'toast'
disabled: not app.enable_toast_1
on_active: app.disable_toast()
BoxLayout:
Label:
text: '+1 Toast'
font_size: 13.0
CheckBox:
id: toast_2
group: 'toast'
disabled: not app.enable_toast_2
on_active: app.disable_toast()
BoxLayout:
Label:
text: '+2 Toast'
font_size: 13.0
CheckBox:
id: toast_3
group: 'toast'
disabled: not app.enable_toast_3
on_active: app.disable_toast()
BoxLayout:
orientation: 'vertical'
Label:
text: 'Coleslaw'
BoxLayout:
orientation: 'horizontal'
Label:
text: 'No Coleslaw'
font_size: 13.0
CheckBox:
group: 'coleslaw'
id: coleslaw_1
disabled: not app.enable_coleslaw_1
on_active: app.disable_coleslaw()
BoxLayout:
Label:
text: '+1 Coleslaw'
font_size: 13.0
CheckBox:
group: 'coleslaw'
id: coleslaw_2
disabled: not app.enable_coleslaw_2
on_active: app.disable_coleslaw()
BoxLayout:
Label:
text: '+2 Coleslaw'
font_size: 13.0
CheckBox:
group: 'coleslaw'
id: coleslaw_3
disabled: not app.enable_coleslaw_3
on_active: app.disable_coleslaw()
BoxLayout:
orientation: 'vertical'
Label:
text: 'Sauce'
BoxLayout:
orientation: 'horizontal'
Label:
text: 'No Sauce'
font_size: 13.0
CheckBox:
group: 'sauce'
id: sauce_1
disabled: not app.enable_sauce_1
on_active: app.disable_sauce()
BoxLayout:
Label:
text: '+1 Sauce'
font_size: 13.0
CheckBox:
group: 'sauce'
id: sauce_2
disabled: not app.enable_sauce_2
on_active: app.disable_sauce()
BoxLayout:
Label:
text: '+2 Sauce'
font_size: 13.0
CheckBox:
group: 'sauce'
id: sauce_3
disabled: not app.enable_sauce_3
on_active: app.disable_sauce()
BoxLayout:
orientation: 'vertical'
Label:
text: 'Chicken Strips'
BoxLayout:
orientation: 'horizontal'
Label:
text: '+2 Chicken Strips'
font_size: 13.0
CheckBox:
group: 'strips'
BoxLayout:
Label:
text: '+3 Chicken Strips'
font_size: 13.0
CheckBox:
group: 'strips'
BoxLayout:
Label:
text: '+4 Chicken Strips'
font_size: 13.0
CheckBox:
group: 'strips'
BoxLayout:
orientation: 'horizontal'
Label:
text: '+5 Chicken Strips'
font_size: 13.0
CheckBox:
group: 'strips'
BoxLayout:
Label:
text: '+20 Chicken Strips'
font_size: 13.0
CheckBox:
group: 'strips'
BoxLayout:
Label:
text: '+50 Chicken Strips'
font_size: 13.0
CheckBox:
group: 'strips'
BoxLayout:
orientation: 'vertical'
Label:
text: 'Drink Choice'
BoxLayout:
orientation: 'horizontal'
Label:
text: 'Lemonade'
font_size: 13.0
CheckBox:
group: 'drinks'
BoxLayout:
Label:
text: 'Dr. Kelp'
font_size: 13.0
CheckBox:
group: 'drinks'
BoxLayout:
Label:
text: 'Diet Dr.Kelp'
font_size: 13.0
CheckBox:
group: 'drinks'
BoxLayout:
orientation: 'horizontal'
Label:
text: 'Pepsi'
font_size: 13.0
CheckBox:
group: 'drinks'
BoxLayout:
Label:
text: 'Diet Pepsi'
font_size: 13.0
CheckBox:
group: 'drinks'
BoxLayout:
Label:
text: 'Water'
font_size: 13.0
CheckBox:
group: 'drinks'
BoxLayout:
Label:
text: 'Sm'
font_size: 13.0
CheckBox:
group: 'drink_size'
Label:
text: 'Md'
font_size: 13.0
CheckBox:
group: 'drink_size'
Label:
text: 'Lg'
font_size: 13.0
CheckBox:
group: 'drink_size'
BoxLayout:
size_hint_y: .25
BoxLayout:
Label:
text: 'Sales Tax: $' + str('{:0.2f}'.format(app.sales_tax))
BoxLayout:
Button:
text: 'Reset'
on_press: app.reset()
Button:
text: 'Make Order'
on_press: app.reset()
BoxLayout:
Label:
text: 'Total: $' + str('{:0.2f}'.format(app.total))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment