You are on page 1of 3

A complete Java program (1 of 2)

Retail Application Case Study


Let us relook at the
Customer class

How can the


objects be
created for this
class?

class Customer {
private int customerld;
private long telephoneNo;
public void setCustomerld(int id} {
customerld = id;
}
public void setTelephoneNo(long teleNo) {
telephoneNo=teleNo;
}
public int getCustomerld() {
return customerld;
}
public long getTelephoneNo() {
return telephoneNo;
}

A complete Java program (2 of 2)


Retail Application Case Study

class Retail {

Note how an
object of
Customer class is
created

public static void main(String args[ ]) {


Customer custObj = new Customer();
custObj.setCustomerld(1001);

Methods of a class
are accessed and
invoked using '.'
(dot) operator

custObj.setTelephoneNo(9201861311L);
System.out.println(Customer ld:+ custObj.getCustomerld());
System.out.printin(Telephone No:+
custObj.getTelephoneNo());
}
}

Retail Application Case Study - Steps Forwards


Retail Application Case Study
The Retail Store needs to keep track of the bill amount paid by
the customer for a purchase. The retail store wants to give some
discount based on the bill amount. Assume discount has to be
identified as per the table given below:
Bill Amount
>=1000
>=500 and
<1000

Discount
%
10
5

What is needed
to implement
this scenario?

To implement the above scenario, we need


a class to store purchase details
logic to calculate the discount based on the table

You might also like