Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ClassTheory;
- import java.util.ArrayList;
- public class Customer {
- private String id,name;
- private ArrayList<Iteam> iteamList=new ArrayList<>();
- private Adress adress;
- public void setAdress(Adress ad){
- this.adress=ad;
- }
- public void getAdress(){
- adress.display();
- }
- public Customer(String i,String n){
- this.id=i;
- this.name=n;
- }
- public void buy(Iteam i){
- iteamList.add(i);
- }
- public void display(){
- System.out.println("Name of customer is "+name);
- for(Iteam i: iteamList){
- i.display();
- }
- }
- }
- package ClassTheory;
- public class Iteam {
- private String iteamId,iteamName;
- private double price;
- public Iteam(String id,String name){
- this.iteamId=id;
- this.iteamName=name;
- }
- public void setPrice(double d){
- this.price=d;
- }
- void display(){
- System.out.println("Iteam name is "+iteamName);
- System.out.println("Iteam Id is "+iteamId);
- System.out.println("Iteam price is "+price);
- }
- }
- package ClassTheory;
- public class Adress {
- private int houseNo,roadNo;
- private String area,city;
- public Adress(int h,int r,String a,String c){
- this.houseNo=h;
- this.roadNo=r;
- this.area=a;
- this.city=c;
- }
- public void display(){
- System.out.println("House no of customer is "+houseNo);
- System.out.println("Road no of customer is "+roadNo);
- System.out.println("Area of customer is "+area);
- System.out.println("City of customer is "+city);
- System.out.println("");
- }
- }
- package ClassTheory;
- public class Test {
- public static void main(String[] args) {
- Iteam choklate = new Iteam("IC_1", "Kitkat");
- choklate.setPrice(65);
- Iteam atta = new Iteam("IA_1", "shaad");
- atta.setPrice(30);
- Adress a1 = new Adress(132, 20, "Mirpur", "Dhaka");
- Adress a2 = new Adress(132, 20, "Dhanmondi", "Dhaka");
- Customer c1 = new Customer("Agor_C11", "Abdul");
- Customer c2 = new Customer("Agor_C11", "Rahim");
- c1.buy(atta);
- c1.buy(choklate);
- c1.display();
- c1.setAdress(a1);
- c1.getAdress();
- c2.buy(choklate);
- c2.buy(atta);
- c2.display();
- c2.setAdress(a2);
- c2.getAdress();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement