region = new ArrayList<>();
regionNumber.add("01"); region.add("TOSHKENT_SHAHAR");
regionNumber.add("10"); region.add("TOSHKENT_VILOYATI");
regionNumber.add("20"); region.add("SIRDARYO");
regionNumber.add("25"); region.add("JIZZAX");
regionNumber.add("30"); region.add("SAMARQAND");
regionNumber.add("40"); region.add("FARG'ONA");
regionNumber.add("50"); region.add("NAMANGAN");
regionNumber.add("60"); region.add("ANDIJON");
regionNumber.add("70"); region.add("QASHQADARYO");
regionNumber.add("75"); region.add("SURXONDARYO");
regionNumber.add("80"); region.add("BUXORO");
regionNumber.add("85"); region.add("NAVOIY");
regionNumber.add("90"); region.add("XORAZM");
regionNumber.add("95"); region.add("QORAQALPOG'ISTON");
for (int i = 0; i < 14; i++) {
AutoNumber autoNumber = new AutoNumber();
autoNumber.setId();
autoNumber.setRegion(region.get(i));
autoNumber.setLetters(letters);
autoNumber.setRegionNumber(regionNumber.get(i));
autoNumber.setNumbers(numbers);
autoNumber.setInitialPrice(initoalPrice);
autoNumber.setStatus(Status.SOTUVDA);
autoNumber.setFullNumber(autoNumber.getRegionNumber()+" "+autoNumber.getNumbers()+" "+autoNumber.getLetters());
autoNumber.setCategories(Categories.YURIDIK_SHAXS);
autoNumberService.add(autoNumber);
changeToPhysical(autoNumber,autoNumberService);
}
}
private static void changeToPhysical(AutoNumber OldAutoNumber, AutoNumberService autoNumberService) {
AutoNumber autoNumber = new AutoNumber();
autoNumber.setId();
autoNumber.setNumbers(OldAutoNumber.getNumbers());
autoNumber.setLetters(OldAutoNumber.getLetters());
autoNumber.setRegionNumber(OldAutoNumber.getRegionNumber());
autoNumber.setRegion(OldAutoNumber.getRegion());
autoNumber.setInitialPrice(OldAutoNumber.getInitialPrice());
autoNumber.setStatus(OldAutoNumber.getStatus());
autoNumber.setCategories(Categories.JISMONIY_SHAXS);
autoNumber.setFullNumber(autoNumber.getRegionNumber()+" "+autoNumber.getLetters().substring(0,1)+" "+autoNumber.getNumbers()+" "+autoNumber.getLetters().substring(1));
autoNumberService.add(autoNumber);
}
public static void addUsers(UserService userService, CardService cardService){
User user = new User("DAVRON","+998944001404","1404","davrondavrik3@gmail.com",Categories.JISMONIY_SHAXS,"TOSHKENT VILOYATI");
user.setId();
Card card = new Card("8600 0423 8669 2833","04/23", CardFront.getBalance());
card.setId();
card.setUserId(user.getId());
cardService.add(card);
Card card1 = new Card("8600 3029 2775 4767","10/24", CardFront.getBalance());
card1.setId();
card1.setUserId(user.getId());
cardService.add(card1);
userService.add(user);
User user1 = new User("PDP","+998334001404","123456","pdp@gmail.com",Categories.YURIDIK_SHAXS,"TOSHKENT SHAXAR");
user1.setId();
Card card2 = new Card("8600 1058 1234 5678","05/22", CardFront.getBalance());
card2.setId();
card2.setUserId(user1.getId());
cardService.add(card2);
Card card3 = new Card("8600 1234 5432 9874","09/24", CardFront.getBalance());
card3.setId();
card3.setUserId(user1.getId());
cardService.add(card3);
userService.add(user1);
}
}
package service.authorization;
import model.authorization.User;
import service.base.BaseService;
import java.util.ArrayList;
import java.util.UUID;
public class UserService implements BaseService {
private ArrayList users = new ArrayList<>();
@Override
public boolean add(Object object) {
User newUser = (User) object;
boolean ans = false;
for (User user : users) {
if (user.getPhoneNumber().equals(newUser.getPhoneNumber())){
ans = true;
break;
}
}
if (!ans){
users.add(newUser);
}
return !ans;
}
@Override
public boolean add(Object object, Object object1) {
return false;
}
@Override
public boolean delete(Object object) {
return false;
}
@Override
public void list() {
}
public User getUser(String phoneNumber, String password){
User user1 = null;
for (User user:users) {
if (user.getPhoneNumber().equals(phoneNumber) && user.getPassword().equals(password)){
user1 = user;
break;
}
}
return user1;
}
public User getUser(UUID id){
for (User user:users) {
if (user.getId().equals(id)){
return user;
}
}
return null;
}
}