How to write a query to get wine pairing for a pizza based on pairing weight

I am working on a query to pair drinks to pizzas. Currently I am able to show the pizza_name, beverage and the pairing_weight being the amount of toppings on a pizza that the beverage pairs with. From here, I am looking to just output a mapping of distinct pizza name to beverage. I am unsure how to format the query to just return the top result per pizza based on pairing_weight.

mysql> select pizza_name, beverage, COUNT(beverage) as pairing_weight     -> from pizza_production     ->     JOIN pizza_restrictions pr on     ->         pizza_production.topping_name = pr.topping_name     ->     JOIN beverage_pairing_notes on     ->         restriction = pairing     ->     GROUP BY pizza_name, beverage     ->     ORDER BY pizza_name, pairing_weight DESC; +--------------+--------------------+----------------+ | pizza_name   | beverage           | pairing_weight | +--------------+--------------------+----------------+ | Grand Padano | Prosecco           |              2 | | Grand Padano | Champagne          |              2 | | Grand Padano | Riesling           |              2 | | Grand Padano | Cava               |              2 | | Grand Padano | Pinot Noir         |              1 | | Grand Padano | Carlsberg beer     |              1 | | Grand Padano | Zinfandel Rosé     |              1 | | Grand Padano | Chardonnay         |              1 | | Grand Padano | Chenin Blanc       |              1 | | Grand Padano | Gewürztraminer     |              1 | | Grand Padano | Guinness beer      |              1 | | Grand Padano | Pinot Grigio       |              1 | | Grand Padano | Heineken beer      |              1 | | Grand Padano | Irn Bru            |              1 | | Grand Padano | Malbec             |              1 | | Grand Padano | Muscat Blanc       |              1 | | new york     | Riesling           |              2 | | new york     | Champagne          |              2 | | new york     | Prosecco           |              2 | | new york     | Pinot Noir         |              2 | | new york     | Malbec             |              2 | | new york     | Syrah              |              1 | | new york     | Cava               |              1 | | new york     | Cabernet Sauvignon |              1 | | new york     | Chardonnay         |              1 | | new york     | Carlsberg beer     |              1 | | new york     | Chenin Blanc       |              1 | | new york     | Gewürztraminer     |              1 | | new york     | Guinness beer      |              1 | | new york     | Muscat Blanc       |              1 | | new york     | Heineken beer      |              1 | | pepperoni    | Pinot Noir         |              3 | | pepperoni    | Malbec             |              3 | | pepperoni    | Muscat Blanc       |              2 | | pepperoni    | Heineken beer      |              2 | | pepperoni    | Guinness beer      |              2 | | pepperoni    | Gewürztraminer     |              2 | | pepperoni    | Chenin Blanc       |              2 | | pepperoni    | Riesling           |              2 | | pepperoni    | Carlsberg beer     |              2 | | pepperoni    | Cabernet Sauvignon |              2 | | pepperoni    | Chardonnay         |              1 | | pepperoni    | Champagne          |              1 | | pepperoni    | Prosecco           |              1 | | pepperoni    | Cava               |              1 | | pepperoni    | Rioja              |              1 | | pepperoni    | Syrah              |              1 | | pepperoni    | Zinfandel Rosé     |              1 | | vegetarian   | Diet Coke          |              2 | | vegetarian   | Prosecco           |              1 | | vegetarian   | Champagne          |              1 | | vegetarian   | Riesling           |              1 | +--------------+--------------------+----------------+ 52 rows in set (0.01 sec) 

An example of desired output would be

+--------------+--------------------+ | pizza_name   | beverage           | +--------------+--------------------+ | pepperoni    | Pinot Noir         | | new york     | Riesling           | | Grand Padano | Prosecco           | | vegetarian   | Diet Coke          | +--------------+--------------------+ 

Is there a way to pull this data from what I already have in the output of the query above? Thank you.

2D Finding an algorithm to check pizza toppings positions

Using unity 3D I am creating a 2D pizza game and I am stuck at finding an algorithm to solve this problem which is Detecting if the pizza is half and half taking into consideration that the user can put the toppings in all rotations shown in the picture and lot more possible distributions.

I used Physics2D.OverlapAreaAll to get position of ingredients on the pizza and I tried getting the sumX and sumY of coordinates of all topping A and sumX and sumY of all topping B and adding A.sumX + B.sumX and A.sumY + B.sumY and if the 2 totals are between 0 and 1 then A and B are on opposite sides but the bad distribution of toppings in the second pic is also accepted by my algorithm. The toppings must be spread like in the 1st pic

I need some easier way to detect the correct distribution of ingredients maybe using collisions or something.

if (sumX > -ErrLvl && sumX < ErrLvl && sumY > -ErrLvl && sumY < ErrLvl)               {                 Debug.Log("APPROVED HALF-HALF PIZZA");             }             else                 Debug.Log("BAD HALF-HALF PIZZA"); 

Correct distribution

Bad distribution

Pizza menu design that makes it easy to find the ingredients you want?

I came across this recently:

bad pizza menu - wall of text

and I thought it could be improved by extracting the common ingredients into columns, like this:

improved - common ingredients in columns

code

I find the table intimidating at first. But once you understand it, it is quite empowering.

I was just wondering if there’s a better way.

Perhaps the solution lies in combining the columns on the right? Example: half way down, the “Anchovies” column becomes “Tuna”.

School project – Pizza price calculator [on hold]

I’ve been working on a program for my ICS3U course at school, and it’s not finished yet in terms of formatting the decimal place, but even without that, I still can’t get the code to run properly. The project requires a text field where a customer can enter the diameter of their pizza in inches. This value can be saved in a variable, but is automatically a string. The conent provided for the assignment says that we then have to convert it to a double variable to use in the calculations. I suspect this is where the problem has occurred, but I’m not certain. I would greatly appreciate if anybody would be willing to review my code and help me identify the error and how to fix it. Thanks. The assignment and code are as follows:

Assignment: The cost of making pizza at a local shop is as follows: Labour cost is $ 1.00 per pizza, regardless of size. Store cost is $ 1.50 per pizza, regardless of size. Materials is $ 0.50 * diameter (diameter is measured in inches). Create a Java application that prompts the user for the size of a pizza and then displays the cost of making the pizza. The application should look similar to the image below. Notice that the output is formatted to 2 decimal places with a dollar sign in front. Remember that this can be accomplished using DecimalFormat as seen in previous activities.

Code: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */

public class PizzaAnyoneGUI extends javax.swing.JFrame {

/**  * Creates new form PizzaAnyoneGUI  */ public PizzaAnyoneGUI() {     initComponents(); }  /**  * This method is called from within the constructor to initialize the form.  * WARNING: Do NOT modify this code. The content of this method is always  * regenerated by the Form Editor.  */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">                           private void initComponents() {      titleLabel = new javax.swing.JLabel();     calculateButton = new javax.swing.JButton();     inchesInput = new javax.swing.JTextField();     inchesLabel = new javax.swing.JLabel();     outputLabel = new javax.swing.JLabel();      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);      titleLabel.setText("Pizza Price Calculator");      calculateButton.setText("Calculate");     calculateButton.addActionListener(new java.awt.event.ActionListener() {         public void actionPerformed(java.awt.event.ActionEvent evt) {             calculateButtonActionPerformed(evt);         }     });      inchesInput.addActionListener(new java.awt.event.ActionListener() {         public void actionPerformed(java.awt.event.ActionEvent evt) {             inchesInputActionPerformed(evt);         }     });      inchesLabel.setText("Enter the diameter of the pizza in inches.");      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());     getContentPane().setLayout(layout);     layout.setHorizontalGroup(         layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)         .addGroup(layout.createSequentialGroup()             .addGap(164, 164, 164)             .addComponent(titleLabel)             .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))         .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                 .addGroup(layout.createSequentialGroup()                     .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                     .addComponent(calculateButton))                 .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()                     .addGap(31, 31, 31)                     .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                         .addGroup(layout.createSequentialGroup()                             .addComponent(outputLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)                             .addGap(0, 0, Short.MAX_VALUE))                         .addGroup(layout.createSequentialGroup()                             .addComponent(inchesLabel)                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 69, Short.MAX_VALUE)                             .addComponent(inchesInput, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))))             .addGap(26, 26, 26))     );     layout.setVerticalGroup(         layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)         .addGroup(layout.createSequentialGroup()             .addComponent(titleLabel)             .addGap(68, 68, 68)             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                 .addComponent(inchesInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                 .addComponent(inchesLabel))             .addGap(29, 29, 29)             .addComponent(calculateButton)             .addGap(18, 18, 18)             .addComponent(outputLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)             .addGap(0, 110, Short.MAX_VALUE))     );      pack(); }// </editor-fold>                          private void inchesInputActionPerformed(java.awt.event.ActionEvent evt) {                                                 // TODO add your handling code here: }                                             private void calculateButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                     String inches ;     int labourcost ;     double storecost ;     double materialcost ;     double total ;      inches = Double.parseDouble (inchesInput.getText ()) ;     labourcost = 1 ;     storecost = 1.5 ;     materialcost = inches * 0.5 ;     total = labourcost + storecost + materialcost ;      outputLabel.setText ("The cost of the pizza is"+total+".") ; }                                                 /**  * @param args the command line arguments  */ public static void main(String args[]) {     /* Set the Nimbus look and feel */     //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">     /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.      * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html       */     try {         for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {             if ("Nimbus".equals(info.getName())) {                 javax.swing.UIManager.setLookAndFeel(info.getClassName());                 break;             }         }     } catch (ClassNotFoundException ex) {         java.util.logging.Logger.getLogger(PizzaAnyoneGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);     } catch (InstantiationException ex) {         java.util.logging.Logger.getLogger(PizzaAnyoneGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);     } catch (IllegalAccessException ex) {         java.util.logging.Logger.getLogger(PizzaAnyoneGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);     } catch (javax.swing.UnsupportedLookAndFeelException ex) {         java.util.logging.Logger.getLogger(PizzaAnyoneGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);     }     //</editor-fold>      /* Create and display the form */     java.awt.EventQueue.invokeLater(new Runnable() {         public void run() {             new PizzaAnyoneGUI().setVisible(true);         }     }); }  // Variables declaration - do not modify                      private javax.swing.JButton calculateButton; private javax.swing.JTextField inchesInput; private javax.swing.JLabel inchesLabel; private javax.swing.JLabel outputLabel; private javax.swing.JLabel titleLabel; // End of variables declaration                    

}