Hey guys, for this code I need to have a proper constructor and I dont know which part of the code to make as a constructor. I thought the prices and the size of the pizza I can make as a constructor but I dont know how to do it.
Here is my code:
import java.util.;
public class Pizza {
public static void main(String[] args)
{
final int NUMBER_CHOICES = 4;
String[] Size = {"S", "M", "L", "X"};
double[] size_prices = {6.99, 8.99, 12.50, 15.00};
String chosenSize;
double pizzaPrice = 0.00;
boolean validChoice = false;
Scanner inputDevice = new Scanner(System.in);
System.out.print("Choose your pizza sizes - S, M, L, or X: ");
chosenSize = inputDevice.nextLine();
for(int s = 0; s < NUMBER_CHOICES; ++s)
{
if(chosenSize == null ? Size[s] == null : chosenSize.equals(Size[s]));
{
validChoice = true;
pizzaPrice = size_prices[s];
}
}
if(validChoice)
System.out.println("The size f your pizza is " +
chosenSize + " and total need to pay is $" + pizzaPrice);
else
System.out.println("Sorry - Wrong size! Please try again");
}
}