fork download
  1. % Callback function for "Make Pizza" button
  2. function MakePizzaButtonPushed(app, event)
  3. % Initialize order details
  4. orderDetails = '';
  5. totalCost = 0;
  6.  
  7. % Get selected crust
  8. selectedCrust = app.CrustGroup.SelectedObject.Text;
  9. orderDetails = [orderDetails, 'Crust: ', selectedCrust, newline];
  10.  
  11. % Get selected sauce
  12. selectedSauce = app.SauceKnob.Value;
  13. orderDetails = [orderDetails, 'Sauce: ', selectedSauce, newline];
  14.  
  15. % Calculate price based on selected crust and sauce
  16. price = 10; % base price
  17. if strcmp(selectedCrust, 'Thin Crust')
  18. price = price + 2;
  19. end
  20. if strcmp(selectedSauce, 'BBQ')
  21. price = price + 1;
  22. end
  23.  
  24. % Get toppings and calculate total cost
  25. toppings = [app.ToppingSwitch1.Value, app.ToppingSwitch2.Value, ...
  26. app.ToppingSwitch3.Value, app.ToppingSwitch4.Value];
  27.  
  28. % Count selected toppings
  29. numToppings = sum(toppings);
  30. totalCost = price + (numToppings * 1); % assuming each topping adds $1
  31.  
  32. % Update order details and cost
  33. orderDetails = [orderDetails, 'Toppings: ', num2str(numToppings), newline];
  34. orderDetails = [orderDetails, 'Total Cost: $', num2str(totalCost), newline];
  35.  
  36. % Display order in the text area
  37. app.OrderTextArea.Value = orderDetails;
  38. app.CostNumericEditField.Value = totalCost;
  39.  
  40. % Simulate pizza making process
  41. app.Lamp.Color = 'yellow'; % Indicate cooking
  42. app.Gauge.Value = 0; % Reset gauge
  43. for i = 1:10
  44. pause(0.5); % Simulate baking time
  45. app.Gauge.Value = i; % Update baking progress
  46. end
  47. app.Lamp.Color = 'green'; % Indicate ready
  48. app.Slider.Value = app.Slider.Value + 1; % Increment pizza count
  49. end
  50.  
Success #stdin #stdout 0.09s 46568KB
stdin
Standard input is empty
stdout
Standard output is empty