int SCALE = 8; void setup() { size( 900, 300 ); smooth(); System.out.println( "We're making pizzas" ); Pizza pepperoni = new Pizza(); Pizza cheese = new Pizza(); Pizza [] allThePizzas = new Pizza [10]; pepperoni.setSize( 14 ); pepperoni.size = 14; System.out.println( "Pepperoni is size: " + pepperoni.getSize() ); cheese.setSize( 20 ); System.out.println( "Cheese is size: " + cheese.getSize() ); String [] x = { "cheese" }; cheese.setToppings( x ); pepperoni.addTopping( "cheese" ); pepperoni.addTopping( "pepperoni" ); System.out.println( "Cheese has: " + cheese.printToppings() ); System.out.println( "Pepperoni has: " + pepperoni.printToppings() ); Customer c1 = new Customer( "Alfred", "201 Alfred Street" ); Customer c2 = new Customer( "Joshua" ); Customer c3 = new Customer( "Patricia" ); c1.order( pepperoni ); c1.order( cheese ); c1.order( cheese ); c1.order( pepperoni ); c1.order( pepperoni ); c1.order( cheese ); System.out.println( c1.printOrders() ); c1.drawPizzas(); } public class Pizza { // Variables int size; String [] toppings; int numToppings; // Constructor public Pizza() { numToppings = 0; toppings = new String [1000]; } void drawPizza( int x ) { int pizzaX = x; int pizzaY = height/2; fill( 204, 150, 100 ); ellipse( pizzaX, pizzaY, size*SCALE, size*SCALE ); fill( 250, 20, 0 ); ellipse( pizzaX, pizzaY, size*SCALE*.91, size*SCALE*.91 ); int counter = 0; while( counter < numToppings ) { if( toppings[counter].equals( "cheese" ) ) { int cheeseCounter = 0; while( cheeseCounter < 3000 ) { fill( random(230,255), random(200,235), random(0,160), 140 ); int w = floor(random(width)); int h = floor(random(height)); if( sqrt((w - pizzaX)*(w - pizzaX) + (h - pizzaY) *(h - pizzaY)) < size*SCALE*.89*.5 ){ noStroke(); //translate( width/2, height/2); //rotate(random(TAU)); ellipse( w, h, 5, 5 ); cheeseCounter++; } } } stroke( 0 ); counter++; } counter = 0; while( counter < numToppings ) { if( toppings[counter].equals( "pepperoni" ) ) { fill( 255, 140, 20 ); int pepperoniCounter = 0; while( pepperoniCounter < 40 ) { int w = floor(random(width)); int h = floor(random(height)); if( sqrt((w - pizzaX)*(w - pizzaX) + (h - pizzaY) *(h - pizzaY)) < size*SCALE*.89*.5 ){ ellipse( w, h, 14, 14 ); pepperoniCounter++; } } } counter++; } } public int getSize() { return size; } public void setSize( int s ) { if( s < 8 || s > 36 ) { size = 10; System.out.println( "Error, pizza size invalid" ); } else { size = s; } } public String [] getToppings() { return toppings; } public void setToppings( String [] t ) { toppings = t; numToppings = t.length; } public void addTopping( String t ) { toppings[numToppings] = t; numToppings++; } public String printToppings() { String printString = ""; int count = 0; while( count < numToppings ) { printString += toppings[count] + " " ; count++; } return printString; } // end of printToppings } // end of Pizza class public class Customer { String name; String address; Pizza [] orderHistory; int numPizzas; public Customer( String n ) { name = n; orderHistory = new Pizza[9001]; numPizzas = 0; } public Customer( String n, String a ) { name = n; address = a; orderHistory = new Pizza[9001]; numPizzas = 0; } public void order( Pizza p ) { orderHistory[ numPizzas ] = p; numPizzas = numPizzas + 1; } public Pizza [] getOrders() { return orderHistory; } public String printOrders() { String ret = ""; int counter = 0; while( counter < numPizzas ) { Pizza temp = orderHistory[ counter ]; ret += temp.printToppings() + " | "; counter++; } return ret; } public void drawPizzas() { int counter = 0; int x = 0; while( counter < numPizzas ) { Pizza temp = orderHistory[ counter ]; x += (temp.getSize()*SCALE)/2 + 5; temp.drawPizza( x ); x += (temp.getSize()*SCALE)/2; counter++; } } }