Semester - BS IT - 02-A Name: Basharat Ali En: 02-235202-047: CSL-113: Object Oriented Programming

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

CSL-113: Object Oriented Programming

Semester –BS IT – 02-A


Name: Basharat Ali
En: 02-235202-047

//goldcustomer

/*

* To change this license header, choose License Headers in Project


Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package testcustomer;

public class Goldcustomer extends Customer{

public int updatedpoints;


CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

public Goldcustomer(String name, String address, int phone_number,


int bill_amount, int points) {

super(name, address, phone_number, bill_amount, points);

public void checkcustomer(){

if(super.bill_amount>=20000 ){

System.out.println("gold customer: " );

else if(super.bill_amount<20000 || super.bill_amount>=10000)

System.out.println("silver customer: " );

else{

System.out.println("general customer: " );


CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

public void updatepoints()

if(super.pointsofloyality > 100 || super.pointsofloyality < 200)

updatedpoints=100-super.pointsofloyality;

}else if(super.pointsofloyality >=200)

updatedpoints=super.pointsofloyality-200;

@Override
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

public void get_bill(){

super.discount=super.bill_amount*0.15;

if(super.pointsofloyality > 100 || super.pointsofloyality <200 )

super.pointsdiscount=super.bill_amount*0.05;

}else if(super.pointsofloyality > 200)

super.pointsdiscount=super.bill_amount*0.08;

super.finaldiscount=super.pointsdiscount+super.discount;

super.totalbill=super.bill_amount - super.finaldiscount;

System.out.println("you are gold customer so your discount


:"+super.discount );

System.out.println(" discount for your points of loyality is


:"+super.pointsdiscount );

System.out.println(" total discount is :"+super.finaldiscount );


CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

System.out.println(" total bill is :"+super.totalbill );

@Override

public void ToString()

System.out.println("Name is: "+super.cust_name);

System.out.println("Phone number is: "+super.cust_phone);

System.out.println("Address is: "+super.cust_Address);

System.out.println("Points of loyality are: "+super.pointsofloyality);

System.out.println("updated points : "+updatedpoints);

System.out.println("Billing amount is: "+super.bill_amount);

System.out.println("discount is : "+finaldiscount);

System.out.println("your final bill after all discounts is :"+totalbill );

}
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

//silver

/*

* To change this license header, choose License Headers in Project


Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package testcustomer;

public class silvercustomer extends Customer {

public int updatedpoints;


CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

public silvercustomer(String name, String address, int phone, int


bill_amount, int points) {

super(name, address, phone, bill_amount, points);

// public void checkcustomer(){

@Override

public void get_bill(){

super.discount=super.bill_amount*0.08;

if(super.pointsofloyality > 100 || super.pointsofloyality <200 )

super.pointsdiscount=super.bill_amount*0.05;

}else if(super.pointsofloyality > 200)

super.pointsdiscount=super.bill_amount*0.08;

super.finaldiscount=super.pointsdiscount+super.discount;
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

totalbill=bill_amount-discount;

System.out.println("you have discount for being silver customer


is :"+super.discount );

System.out.println("you have discount for your points of loyality


is :"+super.pointsdiscount );

System.out.println("your total discount is :"+super.finaldiscount


);

System.out.println("your final bill is :"+super.totalbill );

public void updatepoints()

if(super.pointsofloyality > 100 || super.pointsofloyality < 200)

updatedpoints=super.pointsofloyality-100;

}else if(super.pointsofloyality >=200)


CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

updatedpoints=super.pointsofloyality-200;

@Override

public void ToString()

System.out.println("Name is: "+super.cust_name);

System.out.println("Phone number is: "+super.cust_phone);

System.out.println("Address is: "+super.cust_Address);

System.out.println("Points of loyality are: "+super.pointsofloyality);

System.out.println("updated points : "+updatedpoints);

System.out.println("Billing amount is: "+super.bill_amount);

System.out.println("discount is : "+finaldiscount);

System.out.println("your final bill after all discounts is :"+totalbill );

}
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

void checkcustomer() {

if(super.bill_amount>=20000 ){

System.out.println("gold customer: " );

else if(super.bill_amount<20000 || super.bill_amount>=10000)

System.out.println("silver customer: " );

else{

System.out.println("general customer: " );

}
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

//general

/*

* To change this license header, choose License Headers in Project


Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package testcustomer;

public class generalcustomer extends Customer {

public generalcustomer(String name, String address, int phone, int


bill_amount, int points) {

super(name, address, phone, bill_amount, points);


CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

public void checkcustomer(){

if(super.bill_amount>=20000 ){

System.out.println("gold customer: " );

else if(super.bill_amount<20000 || super.bill_amount>=10000)

System.out.println("silver customer: " );

else{

System.out.println("general customer: " );

@Override
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

public void get_bill(){

System.out.println("you are general customer so you do not have


any discount" );

System.out.println("you do not have discount for your points of


loyality ");

System.out.println("your final bill is :"+super.bill_amount );

@Override

public void ToString()

System.out.println("Name is: "+super.cust_name);

System.out.println("Address is: "+super.cust_Address );

System.out.println("Phone number is: "+super.cust_phone);

System.out.println("Billing amount is: "+super.bill_amount);

System.out.println("Points of loyality are: "+super.pointsofloyality);

}
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

//customer

/*

* To change this license header, choose License Headers in Project


Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package testcustomer;

public class Customer {

protected String cust_name;

protected String cust_Address;

protected int cust_phone;


CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

protected int bill_amount;

protected int pointsofloyality;

public double discount;

public double totalbill;

public double pointsdiscount;

public double finaldiscount;

Customer(String cust_name,String cust_Address,int cust_phone,int


bill_amount,int pointsofloyality)

this.cust_name=cust_name;

this.cust_Address=cust_Address;

this.cust_phone=cust_phone;

this.bill_amount=bill_amount;

this.pointsofloyality=pointsofloyality;
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

public void setName(String name)

cust_name=name;

public String getName()

return cust_name;

public void setAddress(String Address)

cust_Address=Address;

public String getAddress()

return cust_Address;

}
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

public void setphoneNumber(int phone)

cust_phone=phone;

public int getphonenNumber()

return cust_phone;

public void setBillamount(int bill)

bill=bill_amount;

public int getbillamount()

return bill_amount;

public void setpointsofloyality(int points_of_loyality)


CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

pointsofloyality=points_of_loyality;

public int getpointsofloyality()

return pointsofloyality;

public void get_bill(){

discount=bill_amount*0.15;

if(pointsofloyality > 100 || pointsofloyality <200 )

pointsdiscount=bill_amount*0.05;

}else if(pointsofloyality > 200)


CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

pointsdiscount=bill_amount*0.08;

finaldiscount=pointsdiscount+discount;

totalbill=bill_amount - finaldiscount;

System.out.println("you have discount for being gold customer is


:"+discount );

System.out.println("you have discount for your points of loyality


is :"+pointsdiscount );

System.out.println("your total discount is :"+finaldiscount );

System.out.println("your final bill is :"+totalbill );

public void ToString()

System.out.println("Name is: "+getName());

System.out.println("Address is: "+getAddress());


CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

System.out.println("Phone number is: "+getphonenNumber());

System.out.println("Billing amount is: "+getbillamount());

System.out.println("discount is : "+finaldiscount);

System.out.println("Points of loyality are: "+getpointsofloyality());

System.out.println("your final bill after all discounts is :"+totalbill );

//testcustomer
package testcustomer;

import java.util.Scanner;
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

public class TestCustomer{

public static void main(String[] args) {

// TODO code application logic here

Goldcustomer[] cutomerList;

cutomerList = new Goldcustomer[3];

cutomerList[0] = new
Goldcustomer("basharat","laandhi",90367867,260000,132);

cutomerList[0].checkcustomer();

cutomerList[0].get_bill();

cutomerList[0].updatepoints();

cutomerList[0].ToString();

System.out.println();

cutomerList[1] = new
Goldcustomer("Ali","ptharrod",067577,25000,135);
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

cutomerList[1].checkcustomer();

cutomerList[1].get_bill();

cutomerList[1].updatepoints();

cutomerList[1].ToString();

System.out.println();

cutomerList[2] = new
Goldcustomer("akbar","latifabad",7098766,20000,175);

cutomerList[2].checkcustomer();

cutomerList[2].get_bill();

cutomerList[2].updatepoints();

cutomerList[2].ToString();

System.out.println();

silvercustomer[] silvercutomerList;

silvercutomerList = new silvercustomer[3];


CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

silvercutomerList[0] = new
silvercustomer("asif","greentown",7035287,15000,198);

silvercutomerList[0].checkcustomer();

silvercutomerList[0].get_bill();

silvercutomerList[0].updatepoints();

silvercutomerList[0].ToString();

System.out.println();

silvercutomerList[1] = new
silvercustomer("abid","johar",03524567,16000,165);

silvercutomerList[1].checkcustomer();

silvercutomerList[1].get_bill();

silvercutomerList[1].updatepoints();

silvercutomerList[1].ToString();

System.out.println();

silvercutomerList[2] = new
silvercustomer("noor","johar",803524567,18000,110);
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

silvercutomerList[2].checkcustomer();

silvercutomerList[2].get_bill();

silvercutomerList[2].updatepoints();

silvercutomerList[2].ToString();

System.out.println();

Customer[] customerList;

customerList = new Customer[2];

customerList[0] = new
Customer("asim","joharmor",60357869,27000,134);

customerList[0].get_bill();

customerList[0].ToString();

System.out.println();

customerList[1] = new
Customer("asad","digroad",80765,21000,171);

customerList[1].get_bill();

customerList[1].ToString();
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

System.out.println();

generalcustomer[] generalcustomerList;

generalcustomerList = new generalcustomer[2];

generalcustomerList[0] = new
generalcustomer("hadi","bahriatown",403746567,700,182);

generalcustomerList[0].get_bill();

generalcustomerList[0].ToString();

System.out.println();

generalcustomerList[1] = new
generalcustomer("rajab","haris",03524567,700,180);

generalcustomerList[1].get_bill();

generalcustomerList[1].ToString();

System.out.println();
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

output
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047
CSL-113: Object Oriented Programming
Semester –BS IT – 02-A
Name: Basharat Ali
En: 02-235202-047

You might also like