/CustomerDataService Secret
Created
July 25, 2018 12:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.client; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class CustomerDataService { | |
public List<Customer> customerList=new ArrayList<>(); | |
Customer e=new Customer(); | |
public CustomerDataService(){ | |
e.setAddress("Hatay/Antakya"); | |
e.setId("0"); | |
e.setName("Gokhan"); | |
e.setPhoneNumber("15134235322452"); | |
customerList.add(e); | |
} | |
private static CustomerDataService ourInstance=new | |
CustomerDataService(); | |
public static CustomerDataService getInstance(){ | |
return ourInstance; | |
} | |
public String addCustomer(Customer customer){ | |
String newId=Integer.toString(customerList.size()+1); | |
customer.setId(newId); | |
customerList.add(customer); | |
return newId; | |
} | |
public List<Customer> getCustomerList(){ | |
return customerList; | |
} | |
public Customer getCustomerById(String id) { | |
for (Customer customer : customerList) { | |
if (customer.getId().equals(id)) { | |
return customer; | |
} | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment