0% found this document useful (0 votes)
45 views

Crud Operations

The document defines a Customer class with fields to store user information like userId, email, password, name, etc. It includes getter and setter methods for each field. An interface CustomerService is defined with methods to create, update, delete and retrieve customers. A CustomerServiceImpl class implements this interface and provides implementations for each method - it uses a static Customer array to store customer objects. The main method creates a sample customer object and adds it to the array using the createCustomer method.

Uploaded by

B07Shubham Mali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Crud Operations

The document defines a Customer class with fields to store user information like userId, email, password, name, etc. It includes getter and setter methods for each field. An interface CustomerService is defined with methods to create, update, delete and retrieve customers. A CustomerServiceImpl class implements this interface and provides implementations for each method - it uses a static Customer array to store customer objects. The main method creates a sample customer object and adds it to the array using the createCustomer method.

Uploaded by

B07Shubham Mali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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, "[email protected]", "Rajan", "Arun", "Password4");


customerService.createCustomer(rajan);

System.out.println(rajan);
}
}

You might also like