Codingassignmenthelper | Home Codingassignmenthelper | University

Java Code

Assignment Code :


package javaapplication16;
import javax.swing.JOptionPane;

//order class to describe order details

class Order
{
String beverage;
String bread;
String type;
String size;

//constructor

public Order(String bev, String bred, String t, String s)
{
beverage=bev;
bread=bred;
type=t;
size=s;
}

//to get order information

public String getOrderInfo()
{
return ""+beverage+" "+bread+" "+type+" "+size;
}
}

//customer class to represent customer details

class Customer
{
String name;
String address;

//order of the customer

Order order;

//constructor

public Customer(String nam, String addr, Order or)
{
name=nam;
address=addr;
order=or;
}

//to get customer name

public String getCustomerName()
{
return name;
}

//to get delivery address

public String getAddress()
{
return address;
}

//to get order details

public String getOrder()
{
return order.getOrderInfo();
}
}


/**
*
* @author milea
*/

public class JavaApplication16 {

/**
* @param args the command line arguments
*/

public static void main(String[] args) {

// TODO code application logic here
//read necessary information from user

String nam = JOptionPane.showInputDialog("Enter your name: ");
String addr = JOptionPane.showInputDialog("Enter delivery address: ");
String bev = JOptionPane.showInputDialog("Enter beverage: ");
String bred = JOptionPane.showInputDialog("Enter bread: ");
String t = JOptionPane.showInputDialog("Enter type: ");
String s = JOptionPane.showInputDialog("Enter size: ");

//create order object

Order or = new Order(bev, bred, t,s);

//create customer object

Customer customer=new Customer(nam, addr,or);

//create message

String message = "Welcome "+customer.getCustomerName()+" to ***Famous Favorite subs***!\n"+"You ordered "+customer.getOrder()
+"\nto deliver at "+customer.getAddress()+"\nThank you for visiting us.";

//display message

JOptionPane.showMessageDialog (null, message, "Message", JOptionPane.INFORMATION_MESSAGE);
 }
}

To Download Click Here > java code.pdf
Codingassignmenthelper | Home Codingassignmenthelper | Home