UML Diagram to JAVA code [problem 3]

Agora is Shop .Every Shop has location and address .Agora ha outlet number and cell number.Customer buy Item from Agora. Customer has customer id and name.Item has item Id and unit price.Customer buy item as a specific date quantity.

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

UML Diagram

UML Diagram to JAVA code [problem 3] 1

Main Class java code

package ARP;

public class Main {
	public static void main(String[] args)
	{
		Agora agr = new Agora("Dhanmondi","Sukrabad","Adi sukrabad","017*****");
		Item itm = new Item(10,"Kacchi",130.0);
		Customer cr =new Customer("15","Kamal");
		Outlet ot= new Outlet(agr,itm);
		Buy buy = new Buy(cr,itm,"1 November 2019",1);
		ot.display();
		buy.display();
		
	}

}

Customer class Java code

package ARP;

public class Customer {
	
	private String cusId;
	private String name;

	public Customer (String cusId,String name)
	{
		this.cusId=cusId;
		this.name=name;
	}
	public void display()
	{
		System.out.println("Customer ID:"+cusId);
		System.out.println("Customer Name:"+name);
	}
}

Buy class java code

package ARP;

public class Buy {

	private String date;
	private int qty;
	
	Customer customer;
	Item item;
	
	public Buy(Customer customer,Item item,String date,int qty)
	{
		this.customer=customer;
		this.item=item;
		this.date=date;
		this.qty=qty;
	}
	public void display()
	{
		customer.display();
		item.display();
		System.out.println("Date :"+date);
		System.out.println("Quantity :"+qty);
	}
}

Outlet class java code

package ARP;

public class Outlet {
	Agora agora;
	Item item;
	
	public Outlet(Agora agora,Item item)
	{
		this.agora=agora;
		this.item=item;
	}
	public void display()
	{
		agora.display();
		item.display();
	}

}

Item Class java code

package ARP;

public class Item {
	private int itemId;
	private String name;
	private double price;

	public Item(int itemId,String name,double price)
	{
		this.itemId=itemId;
		this.name=name;
		this.price=price;
	}
	public void display()
	{
		System.out.println("Item ID: "+itemId);
        System.out.println("Item Name :"+name);
        System.out.println("Price :"+price);
		
	}
}

Shop class java code

package ARP;


public class Shop {

	protected String location;
	protected String address;
	public Shop(String location,String address)

		{
			this.location=location;
			this.address=address;
	    }
	
	public void display()
	{
		System.out.println("Location :"+location+"\n"+"Address :"+address);
		
	}
	
}

Agora class java code

package ARP;

public class Agora extends Shop {
	private String outlet;
	private String cell;
	
	public Agora(String location,String address,String outlet,String cell)
	{
		super(location,address);
		this.outlet=outlet;
		this.cell=cell;
	}
	public void display()
	{
		super.display();
		System.out.println("Outlet :"+outlet+"\n"+cell);
	}

}

Output

UML Diagram to JAVA code [problem 3] 2
Output

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Do You Want To Contact With me?

drop us a line and keep in touch