Java Programming (Object Oriented Programming): The Java Program consists of thr
ID: 665080 • Letter: J
Question
Java Programming (Object Oriented Programming):
The Java Program consists of three classes. The first Main class called orders, which contains the name, purchaseDate. similarly, the second class (Sub class) contains the address and the zip code. whereare the last class (sub-class) contains the productName and the Number of items.
The program should create 5 order objects for testing.
The output of the program:
Press 1 for displaying Names \This will display only the names
Press 2 for displaying Zip Codes \This will display the zip codes for all the orders
Press 3 for displaying Product Names \This will display all the products ordered
Press 4 for Displaying all the data \This will display information for all the orders
Press 5 for closing the program \For closing the program
Explanation / Answer
public class Orders
{
private Srting name ;
private Srting purchaseDate;
public Orders()
{
name = 0;
purchaseDate = 0 ;
}
public Orders(String g, String p)
{
name = g;
purchaseDate = p;
}
public void display()
{
System.out.print(name + " ");
}
}
public class Delievery extends Orders
{
private Srting address ;
private Srting zipcode;
public Delievery()
{
address = 0;
zipcode = 0 ;
}
public Delievery(String a, String z)
{
address = a;
zipcode = z;
}
public void display()
{
System.out.print(zipcode + " ");
}
}
public class Product extends Delievery
{
private Srting productName ;
private int Item_number;
public Product()
{
productName = 0;
Item_number = 0 ;
}
public Product(String pro, String i)
{
productName = pro;
Item_number = i;
}
public void display()
{
System.out.print(productName + " ");
}
}
public class Test
{
public static void main(String args[])
{
Orders ord = new Orders(); // Creates object of order class
Delievery del = new Delievery(); // Creates object of Delievery
Product Pr = new Product(); // // Creates object of product class
ord.display()
del.display();
Pr.display();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.