Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Crud Operations

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

class Customer{

int userId;
String emailId;
String password;
String firstName;
String lastName;
String gender;
String phoneNo;
String city;

public Admin(){
super();
}

public Admin(int userId, String emailId, String password, String firstName, String
lastName,, String city String gender, String phoneNo ){

super();

this.userId = userId;
this.emailId = emailId;
this.password = password;
this.firstName = firstName;
this.lastName = lastName;
this.city = city;
this.gender = gender;
this.phoneNo;

public int getuserId(){


return this.userId;
}
public void setuserId(int userId){
this.userId = userId;
}

public String getemailId(){


return this.emailId;
}
public void setemailId(String emailId){
this.emailId = emailId;
}

public String getpassword(){


return this.password;
}

public void setpassword(String password){


this.password = password;
}

public String getfirstName(){


return this.firstName;
}
public void setfirstName(String firstName){
this.firstName = firstName;
}

public String getlastName(){


return this.lastName;
}
public void setlastName(String lastName){
this.lastName = lastName;
}

public String getcity(){


return this.city;
}
public void setcity(String city){
this.city = city;
}

public String getgender(){


return this.gender;
}
public void setgender(String gender){
this.gender = gender;
}

public String getphoneNo(){


return this.phoneNo;
}
public void setphoneNo(String phoneNo){
this.phoneNo = phoneNo;
}

@Override
public String toString(){
return "Customer[userId="+userId+", emailId="+emailId+",password
="+password+" ,firstName="+firstName+", lastName="+lastName+",city =
"+city+",gender = "+gender+",phoneNo = "+phoneNo+"]";
}
}

interface CustomerService{
void createCustomer(Customer customer);
Customer updateAdmin(Customer customer);
void deleteCustomer(int id);
Customer[] getCustomer();
}

class CustomerServiceImpl implements CustomerService{


public static Customer customerArray[] = new Customer[5];
static int count = 0;

@Override
public void createCustomer(Customer Customer)
{
CustomerArray[count] = Customer;
count++;
}

@Override
public Admin updateCustomer(Customer customer)
{
for(int i = 0; i < customerArray.length; i++)
{
if(customerArray[i].getuserId() == customer.getuserId()){
customerArray[i] = customer;
return customer;
}
}
return customer;
}

@Override
public void deleteCustomer(int userId)
{
for(int i = 0; i < adminArray.length; i++)
{
if(customerArray[i].getuserId() == userId)
{
adminArray[i] = null;
}
}
}

@Override
public Customer[] getcustomer(){
return customerArray;
}
}

public class Source{


public static void main(String args[]){
customerService customerService = new CustomerServiceImpl();

Admin rajan = new Admin(1004, "rajan@gmail.com", "Rajan", "Arun", "Password4");


customerService.createCustomer(rajan);

System.out.println(rajan);
}
}

You might also like