UML Diagram to JAVA code [problem 5]

UML Diagram

problem5
Problem 5 uml

BuyLaptop class java code

package ARP;

public class BuyLaptop {
	Customer customer;
	Laptop laptop;
	public String date ;
	public int qty;
	
	public BuyLaptop(Customer customer,Laptop laptop,String date,int qty)
	{
		this.customer=customer;
		this.laptop=laptop;
		this.date=date;
		this.qty=qty;
	}
	public void display()
	{
		customer.display();
		laptop.display();
		System.out.println("Date:"+date+"\nQuantity :"+qty);
		laptop.onService();
		laptop.offService();
		
	}

}

Customer class java code

package ARP;

public class Customer extends User {
	private String email,cellNO;
	
	public Customer(String name,String loginID,String password,String email,String cellNO)
	{
		super(name,loginID,password);
		this.email=email;
		this.cellNO=cellNO;
	}
	public void display()
	{
		super.display();
		System.out.println("Email:"+email+"\nCell NO:"+cellNO);
	}

}

ElectronicGadget class java code

package ARP;

public class ElectronicGadget {
	protected String menufacturer;

	public ElectronicGadget(String menufacturer)
	{
		this.menufacturer=menufacturer;
	}
	
	public void display()
	{
		System.out.println("Menufacturer :"+menufacturer);
	}
}

Laptop class java code

package ARP;

public class Laptop extends ElectronicGadget {
	private String name,price,powerpack;
	
	public Laptop(String menufacturer,String name,String price,String powerpack)
	{
		super(menufacturer);
		this.name=name;
		this.price=price;
		this.powerpack=powerpack;
	}
	public void display()
	{
		super.display();
		System.out.println("Name:"+name+"\nPrice :"+price+"\nPowerpack :"+powerpack);
	}
	public void onService()
	{
		System.out.println("On Service :2 Years international Warranty, Battery and Charger 1 Year Warranty");
		
	}
	
	public void offService()
	{
		System.out.println("OFF Service :Not available");
	}

}

Main class java code

package ARP;

public class Main {
	public static void main(String[] args)
	{
		Customer cr = new Customer ("Nurnobi Hosen","8748456","nh123456","mdnurnobihosen1@gmail.com","01770634816");
		Laptop lp = new Laptop("ASUS","X542U","84,000","Output: 19V DC, 3.42A, 65W , Input : 100~240V AC, 50/60Hz universal");
		BuyLaptop bl = new BuyLaptop(cr,lp,"1 November 2019",1);
		bl.display();
	}

}

User class java code

package ARP;

public class User {
	protected String name,loginID,password;
	public User(String name,String loginID,String password)
	{
		this.name=name;
		this.loginID=loginID;
		this.password=password;
	}
	
	public void display()
	{
		System.out.println("Name :"+name+"\nLogin ID:"+loginID+"\nPassword :"+password);
	}
	

}

OUTPUT

UML Diagram to JAVA code [problem 5] 1
Output
Posted in Java Programming, UML DiagramTags: