package com.example.pizzeria; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.ImageView; import com.example.pizzeria.ui.CurrentOrderActivity; import com.example.pizzeria.ui.OrderForumActivity; import com.example.pizzeria.ui.StoreOrdersActivity; import com.example.pizzeria.pizzeria.*; import java.math.RoundingMode; import java.text.DecimalFormat; /** This class stores information used in the main page. @author Andy Xu, Jeffrey Zhang */ public class MainActivity extends AppCompatActivity { public static int currentOrderNumber = 1; public static Order currentOrder = new Order(currentOrderNumber); public static StoreOrder storeOrders = new StoreOrder(); public static DecimalFormat format = new DecimalFormat("0.00"); /** Prepares and displays the view. @param savedInstanceState any information from the last time this page was accessed. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView img = findViewById(R.id.imageView1); img.setImageResource(R.drawable.ny_pizza); img = findViewById(R.id.imageView2); img.setImageResource(R.drawable.current_order); img = findViewById(R.id.imageView3); img.setImageResource(R.drawable.store_orders); format.setRoundingMode(RoundingMode.HALF_UP); } /** Starts the order forum activity. @param view the current view. */ public void toOrderForum(View view) { Intent intent = new Intent(this, OrderForumActivity.class); startActivity(intent); } /** Starts the current order activity. @param view the current view. */ public void toOrders(View view) { Intent intent = new Intent(this, CurrentOrderActivity.class); startActivity(intent); } /** Starts the store order activity. @param view the current view. */ public void toStore(View view) { Intent intent = new Intent(this, StoreOrdersActivity.class); startActivity(intent); } /** Adds a pizza to the current order. @param object the pizza object to add to the order. */ public static void addToOrder(Object object) { if (object instanceof Pizza) { currentOrder.add(object); } } /** Places the current order to store orders. */ public static void placeOrder() { storeOrders.add(currentOrder); currentOrderNumber++; currentOrder = new Order(currentOrderNumber); } }