import javax.swing.JComponent;
import javax.swing.JLabel;
public class DataViewUpdater {
    public void updateViewStatus(JComponent errorDisplay, JComponent dataDisplay, boolean isDataRequestSuccessful) {
        if (isDataRequestSuccessful) {
            errorDisplay.setVisible(false);
            dataDisplay.setVisible(true);
        } else {
            errorDisplay.setVisible(true);
            dataDisplay.setVisible(false);
        }
    }
    public static void main(String[] args) {
        JLabel errorLabel = new JLabel("错误：无法加载数据。");
        JLabel dataLabel = new JLabel("数据加载成功！");
        DataViewUpdater updater = new DataViewUpdater();
        updater.updateViewStatus(errorLabel, dataLabel, true);
        System.out.println("数据请求成功时的可见性状态：");
        System.out.println("错误消息可见性：" + errorLabel.isVisible());
        System.out.println("数据视图可见性：" + dataLabel.isVisible());
        updater.updateViewStatus(errorLabel, dataLabel, false);
        System.out.println("数据请求失败时的可见性状态：");
        System.out.println("错误消息可见性：" + errorLabel.isVisible());
        System.out.println("数据视图可见性：" + dataLabel.isVisible());
    }
}

Please write a Java method for toggling the display status in a graphical user interface. When the user requests data, we need to hide the error message and display the data view. Your method should be named `updateViewStatus` and accept two parameters: `errorDisplay` and `dataDisplay`, which represent the error message and the data view UI components, respectively. Use the `JComponent` class from the Java Swing library to represent these UI components, and in your method, set the visibility of these components according to the situation. If the data request is successful, hide the error message and display the data view; if the data request fails, perform the opposite action.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import javax.swing.JComponent;
import javax.swing.JLabel;
public class DataViewUpdater {
    public void updateViewStatus(JComponent errorDisplay, JComponent dataDisplay, boolean isDataRequestSuccessful) {
    }
}
```

import javax.swing.JComponent;
import javax.swing.JLabel;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class DataViewUpdaterTest {
    @Test
    public void testUpdateViewStatus_DataRequestSuccessful() {
        JLabel errorLabel = new JLabel("错误：无法加载数据。");
        JLabel dataLabel = new JLabel("数据加载成功！");
        DataViewUpdater updater = new DataViewUpdater();
        updater.updateViewStatus(errorLabel, dataLabel, true);
        assertFalse(errorLabel.isVisible());
        assertTrue(dataLabel.isVisible());
    }
    @Test
    public void testUpdateViewStatus_DataRequestFailed() {
        JLabel errorLabel = new JLabel("错误：无法加载数据。");
        JLabel dataLabel = new JLabel("数据加载成功！");
        DataViewUpdater updater = new DataViewUpdater();
        updater.updateViewStatus(errorLabel, dataLabel, false);
        assertTrue(errorLabel.isVisible());
        assertFalse(dataLabel.isVisible());
    }
    @Test
    public void testUpdateViewStatus_InitiaVisibility() {
        JLabel errorLabel = new JLabel("错误：无法加载数据。");
        JLabel dataLabel = new JLabel("数据加载成功！");
        errorLabel.setVisible(true);
        dataLabel.setVisible(false);
        DataViewUpdater updater = new DataViewUpdater();
        updater.updateViewStatus(errorLabel, dataLabel, true);
        assertFalse(errorLabel.isVisible());
        assertTrue(dataLabel.isVisible());
        updater.updateViewStatus(errorLabel, dataLabel, false);
        assertTrue(errorLabel.isVisible());
        assertFalse(dataLabel.isVisible());
    }
}


import java.util.HashMap;
import java.util.Map;
public class EntityTypeInformation {
    public static String getEntityTypeInformation(String projectName, String entityTypeName) {
        EntityTypeFetcher entityTypeFetcher = new EntityTypeFetcher();
        return entityTypeFetcher.fetchEntityType(projectName, entityTypeName);
    }
    static class EntityTypeFetcher {
        public String fetchEntityType(String projectName, String entityTypeName) {
            Map<String, String> mockData = new HashMap<>();
            mockData.put("ProjectA:EntityType1", "信息1");
            mockData.put("ProjectB:EntityType2", "信息2");
            return mockData.getOrDefault(projectName + ":" + entityTypeName, "未找到信息");
        }
    }
    public static void checkFunction() {
        String result1 = getEntityTypeInformation("ProjectA", "EntityType1");
        System.out.println("查询结果1: " + result1);
        assert "信息1".equals(result1) : "测试1失败";
        String result2 = getEntityTypeInformation("ProjectB", "EntityType2");
        System.out.println("查询结果2: " + result2);
        assert "信息2".equals(result2) : "测试2失败";
        String result3 = getEntityTypeInformation("ProjectC", "EntityType3");
        System.out.println("查询结果3: " + result3);
        assert "未找到信息".equals(result3) : "测试3失败";
    }
    public static void main(String[] args) {
        checkFunction();
    }
}

Please write a Java method that can query and return the entity type information in a specific project. The method should accept two string parameters: `projectName` and `entityTypeName`, and return a string representing the entity type information. Assume you already have a client class named `EntityTypeFetcher` with a method named `fetchEntityType` that takes a project name and an entity type name as parameters and returns information about the entity type.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.HashMap;
import java.util.Map;
public class EntityTypeInformation {
    public static String getEntityTypeInformation(String projectName, String entityTypeName) {
    }
    static class EntityTypeFetcher {
        public String fetchEntityType(String projectName, String entityTypeName) {
        }
    }
}
```

Question: Write a piece of python code to achieve the following function.
Find the maximum perfect square number that is less than the nth Fibonacci number.
The function's name is max_square_number, and the input is an integer n.

Answer:
```python
def max_square_number(n):
 if n <= 2:
 return 0 # For the first two numbers in the Fibonacci sequence, no complete square numbers can be used.

 fibs = [0, 1] # Store the first two numbers of the Fibonacci sequence
 squares = [] # Store the list of perfect square numbers

 max_square = 0
 i = 2

 while i <= n:
 fibs.append(fibs[i-1] + fibs[i-2]) # Calculate the next Fibonacci number
 i += 1

 fib = fibs[-1]
 perfect_squares = [i**2 for i in range(1, int(math.sqrt(fib)) + 1)]
 max_square = max(filter(lambda x: x < fib, perfect_squares))
 return max_square
```

----------------

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class EntityTypeInformationTest {
    @Test
    public void testGetEntityTypeInformation_ExistingProjectAndEntityType() {
        String result = EntityTypeInformation.getEntityTypeInformation("ProjectA", "EntityType1");
        assertEquals("信息1", result);
    }
    @Test
    public void testGetEntityTypeInformation_ExistingProjectAndDifferentEntityType() {
        String result = EntityTypeInformation.getEntityTypeInformation("ProjectB", "EntityType2");
        assertEquals("信息2", result);
    }
    @Test
    public void testGetEntityTypeInformation_NonExistingProjectAndEntityType() {
        String result = EntityTypeInformation.getEntityTypeInformation("ProjectC", "EntityType3");
        assertEquals("未找到信息", result);
    }
    @Test
    public void testGetEntityTypeInformation_EmptyProjectName() {
        String result = EntityTypeInformation.getEntityTypeInformation("", "EntityType1");
        assertEquals("未找到信息", result);
    }
    @Test
    public void testGetEntityTypeInformation_EmptyEntityTypeName() {
        String result = EntityTypeInformation.getEntityTypeInformation("ProjectA", "");
        assertEquals("未找到信息", result);
    }
}


import java.lang.IllegalArgumentException;
public class RectangleCalculator {
    public static int calculateArea(int width, int height) {
        if (width < 0 || height < 0) {
            throw new IllegalArgumentException("宽度和高度必须非负。");
        }
        return width * height;
    }
    public static void main(String[] args) {
        int width = 5;
        int height = 10;
        int area = calculateArea(width, height);
        System.out.println("矩形的面积是: " + area);
        checkCalculateArea();
    }
    private static void checkCalculateArea() {
        assert calculateArea(5, 10) == 50 : "计算错误";
        assert calculateArea(0, 0) == 0 : "计算错误";
        try {
            calculateArea(-1, 10);
            System.out.println("应该抛出异常，但没有抛出。");
        } catch (IllegalArgumentException e) {
            System.out.println("正确抛出异常，因为输入了负值。");
        }
    }
}

Please write a Java program to implement a class named `RectangleCalculator`, which contains a method `calculateArea` to calculate the area of a rectangle. The method accepts two integer parameters: the rectangle's width `width` and height `height`, and returns the calculated area.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.lang.IllegalArgumentException;
public class RectangleCalculator {
    public static int calculateArea(int width, int height) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class RectangleCalculatorTest {
    @Test
    public void testCalculateAreaPositiveValues() {
        int width = 5;
        int height = 10;
        int expectedArea = 50;
        int actualArea = RectangleCalculator.calculateArea(width, height);
        assertEquals(expectedArea, actualArea);
    }
    @Test
    public void testCalculateAreaZeroValues() {
        int width = 0;
        int height = 0;
        int expectedArea = 0;
        int actualArea = RectangleCalculator.calculateArea(width, height);
        assertEquals(expectedArea, actualArea);
    }
    @Test
    public void testCalculateAreaNegativeWidth() {
        int width = -1;
        int height = 10;
        assertThrows(IllegalArgumentException.class, () -> {
            RectangleCalculator.calculateArea(width, height);
        });
    }
    @Test
    public void testCalculateAreaNegativeHeight() {
        int width = 10;
        int height = -1;
        assertThrows(IllegalArgumentException.class, () -> {
            RectangleCalculator.calculateArea(width, height);
        });
    }
    @Test
    public void testCalculateAreaBothNegative() {
        int width = -5;
        int height = -10;
        assertThrows(IllegalArgumentException.class, () -> {
            RectangleCalculator.calculateArea(width, height);
        });
    }
}


import java.util.Arrays;
import java.util.List;
class UserNotFoundException extends RuntimeException {
    public UserNotFoundException(String message) {
        super(message);
    }
}
public class UserCheckService {
    private List<Long> existingUserIds = Arrays.asList(1001L, 1002L, 1003L, 1004L);
    public void checkUserExistence(long userId) {
        if (!existingUserIds.contains(userId)) {
            throw new UserNotFoundException("用户记录未找到，ID: " + userId);
        }
    }
    public static void main(String[] args) {
        UserCheckService service = new UserCheckService();
        try {
            service.checkUserExistence(1005L);
        } catch (UserNotFoundException e) {
            System.out.println(e.getMessage());
        }
        try {
            service.checkUserExistence(1002L);
            System.out.println("用户存在检查通过");
        } catch (UserNotFoundException e) {
            System.out.println(e.getMessage());
        }
    }
}

Let's assume you are developing a backend service for an e-commerce platform, and you need to write a method to check whether a user exists in the database. If the user does not exist, your method should throw a custom exception indicating "User record not found." Based on this requirement, design a Java method, and ensure your code snippet is fully self-contained, including necessary import statements.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.Arrays;
import java.util.List;
class UserNotFoundException extends RuntimeException {
    public UserNotFoundException(String message) {
        super(message);
    }
}
public class UserCheckService {
    private List<Long> existingUserIds = Arrays.asList(1001L, 1002L, 1003L, 1004L);
    public void checkUserExistence(long userId) {
    }
}
```

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class UserCheckServiceTest {
    private final UserCheckService service = new UserCheckService();
    @Test
    public void testUserExists() {
        Assertions.assertDoesNotThrow(() -> service.checkUserExistence(1001L));
    }
    @Test
    public void testUserNotFoundThrowsException() {
        Assertions.assertThrows(UserNotFoundException.class, () -> service.checkUserExistence(1005L));
    }
    @Test
    public void testUserNotFoundExceptionMessage() {
        UserNotFoundException exception = Assertions.assertThrows(UserNotFoundException.class, () -> service.checkUserExistence(1006L));
        Assertions.assertEquals("用户记录未找到，ID: 1006", exception.getMessage());
    }
    @Test
    public void testUserExistenceOnBoundary() {
        Assertions.assertDoesNotThrow(() -> service.checkUserExistence(1004L));
    }
    @Test
    public void testUserExistenceForNonExistingIdNegative() {
        Assertions.assertThrows(UserNotFoundException.class, () -> service.checkUserExistence(-1L));
    }
}


import java.lang.Math;
public class ImageScaler {
    public static int computeScaleFactor(int originalWidth, int originalHeight, int targetWidth, int targetHeight) {
        int scaleFactor = 1;
        if (originalHeight > targetHeight || originalWidth > targetWidth) {
            int halfHeight = originalHeight / 2;
            int halfWidth = originalWidth / 2;
            while ((halfHeight / scaleFactor) >= targetHeight && (halfWidth / scaleFactor) >= targetWidth) {
                scaleFactor *= 2;
            }
        }
        return scaleFactor;
    }
    public static void main(String[] args) {
        int scaleFactor = computeScaleFactor(4000, 3000, 800, 600);
        System.out.println("Recommended scale factor: " + scaleFactor);
    }
}

How to design a Java method to calculate the appropriate scaling ratio for an image loaded into memory? Assume you need to load an image, but to save memory, you want to calculate a scaling ratio based on the original size of the image and the target display size. This scaling ratio should be a power of 2 (e.g., 1, 2, 4, 8...) to ensure the image does not lose too much quality when scaled. At the same time, the calculated scaling ratio should ensure that the width and height of the scaled image are not less than the target dimensions. Please design a method to achieve this functionality.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.lang.Math;
public class ImageScaler {
    public static int computeScaleFactor(int originalWidth, int originalHeight, int targetWidth, int targetHeight) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class ImageScalerTest {
    @Test
    public void testComputeScaleFactor_NoScalingNeeded() {
        int result = ImageScaler.computeScaleFactor(800, 600, 800, 600);
        assertEquals(1, result);
    }
    @Test
    public void testComputeScaleFactor_ScalingDown() {
        int result = ImageScaler.computeScaleFactor(4000, 3000, 800, 600);
        assertEquals(4, result);
    }
    @Test
    public void testComputeScaleFactor_ScalingDownToDifferentAspectRatio() {
        int result = ImageScaler.computeScaleFactor(4000, 3000, 1000, 800);
        assertEquals(2, result);
    }
    @Test
    public void testComputeScaleFactor_ExactFit() {
        int result = ImageScaler.computeScaleFactor(2000, 1000, 1000, 500);
        assertEquals(2, result);
    }
    @Test
    public void testComputeScaleFactor_OneDimensionFits() {
        int result = ImageScaler.computeScaleFactor(2000, 1000, 2000, 500);
        assertEquals(1, result);
    }
}


import java.util.Objects;
public class UserProfile {
    private String description;
    public UserProfile(String description) {
        this.description = description;
    }
    public String getDescription() {
        if (Objects.isNull(description)) {
            setDescription("暂无描述");
        }
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public static void checkDescription() {
        UserProfile userWithDescription = new UserProfile("爱好编程");
        UserProfile userWithoutDescription = new UserProfile(null);
        System.out.println("有描述的用户描述信息: " + userWithDescription.getDescription());
        System.out.println("无描述的用户描述信息: " + userWithoutDescription.getDescription());
    }
    public static void main(String[] args) {
        checkDescription();
    }
}

Please write a Java method that handles a user's personal description information. In our application, the user's description information may not be set yet, that is, it may be null. If the user's description information is null, we want to automatically generate a default description "No description available".
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.Objects;
public class UserProfile {
    private String description;
    public UserProfile(String description) {
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
    }
}
```

import org.junit.Test;
import static org.junit.Assert.*;
public class UserProfileTest {
    @Test
    public void testGetDescription_whenDescriptionIsNotNull() {
        UserProfile userProfile = new UserProfile("爱好编程");
        assertEquals("爱好编程", userProfile.getDescription());
    }
    @Test
    public void testGetDescription_whenDescriptionIsNull() {
        UserProfile userProfile = new UserProfile(null);
        assertEquals("暂无描述", userProfile.getDescription());
    }
    @Test
    public void testSetDescription() {
        UserProfile userProfile = new UserProfile(null);
        userProfile.setDescription("新描述");
        assertEquals("新描述", userProfile.getDescription());
    }
    @Test
    public void testGetDescription_afterSettingDescription() {
        UserProfile userProfile = new UserProfile(null);
        userProfile.setDescription("新的描述");
        assertEquals("新的描述", userProfile.getDescription());
    }
    @Test
    public void testGetDescription_initialNonNullThenSetNull() {
        UserProfile userProfile = new UserProfile("原描述");
        userProfile.setDescription(null);
        assertEquals("暂无描述", userProfile.getDescription());
    }
}


import java.util.HashMap;
import java.util.Map;
class ProductService {
    private Map<String, Double> productPrices = new HashMap<>();
    public ProductService() {
        productPrices.put("A123", 99.99);
        productPrices.put("B456", 199.99);
        productPrices.put("C789", 299.99);
    }
    public void updateProductPrice(String productId, double newPrice) {
        if (newPrice < 0) {
            throw new IllegalArgumentException("价格不能为负数。");
        }
        productPrices.put(productId, newPrice);
    }
    public double getProductPrice(String productId) {
        return productPrices.getOrDefault(productId, -1.0);
    }
}
public class UpdatePriceDemo {
    public static void main(String[] args) {
        ProductService productService = new ProductService();
        try {
            productService.updateProductPrice("A123", 109.99);
            System.out.println("更新后的价格: " + productService.getProductPrice("A123"));
            productService.updateProductPrice("B456", -99.99);
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        }
    }
}

Please write a Java method to update the price information for a product in an online store. The method should accept two parameters: one is the product ID (of type String), and the other is the new price (of type float). Assume we already have a class named `ProductService`, which has a method called `updateProductPrice` that can be used to update the product price. Additionally, make sure to verify that the new price is not negative before updating it. If the price is negative, the method should throw an `IllegalArgumentException`.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.HashMap;
import java.util.Map;
class ProductService {
    private Map<String, Double> productPrices = new HashMap<>();
    public ProductService() {
    }
    public void updateProductPrice(String productId, double newPrice) {
    }
    public double getProductPrice(String productId) {
    }
}
```

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class ProductServiceTest {
    private ProductService productService;
    @BeforeEach
    public void setUp() {
        productService = new ProductService();
    }
    @Test
    public void testUpdateProductPriceSuccessfully() {
        productService.updateProductPrice("A123", 109.99);
        assertEquals(109.99, productService.getProductPrice("A123"));
    }
    @Test
    public void testUpdateProductPriceWithNegativeValue() {
        Exception exception = assertThrows(IllegalArgumentException.class, () -> {
            productService.updateProductPrice("B456", -99.99);
        });
        assertEquals("价格不能为负数。", exception.getMessage());
    }
    @Test
    public void testGetProductPriceForNonExistingProduct() {
        assertEquals(-1.0, productService.getProductPrice("X999"));
    }
    @Test
    public void testInitialProductPrice() {
        assertEquals(99.99, productService.getProductPrice("A123"));
        assertEquals(199.99, productService.getProductPrice("B456"));
        assertEquals(299.99, productService.getProductPrice("C789"));
    }
    @Test
    public void testUpdatePriceMultipleTimes() {
        productService.updateProductPrice("A123", 109.99);
        productService.updateProductPrice("A123", 119.99);
        assertEquals(119.99, productService.getProductPrice("A123"));
    }
}


import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
class ImageConfig {
    private boolean centerCrop;
    private int priority;
    public ImageConfig() {
    }
    public ImageConfig centerCrop() {
        this.centerCrop = true;
        return this;
    }
    public ImageConfig priority(int priority) {
        this.priority = priority;
        return this;
    }
    public boolean isCenterCrop() {
        return centerCrop;
    }
    public int getPriority() {
        return priority;
    }
}
public class ImageLoader {
    private static ImageConfig imageConfig;
    private static final Lock lock = new ReentrantLock();
    public static ImageConfig getImageConfig() {
        if (imageConfig == null) {
            lock.lock();
            try {
                if (imageConfig == null) {
                    imageConfig = new ImageConfig()
                            .centerCrop()
                            .priority(1);
                }
            } finally {
                lock.unlock();
            }
        }
        return imageConfig;
    }
    public static void main(String[] args) {
        ImageConfig config = ImageLoader.getImageConfig();
        System.out.println("CenterCrop: " + config.isCenterCrop());
        System.out.println("Priority: " + config.getPriority());
    }
}

Please write a Java method that creates and returns an `ImageConfig` object configured with image loading parameters. If the object has already been created, the method should directly return the existing object; otherwise, it should create a new object and set the following parameters: crop the image to fit the center of the view, and set the loading priority to normal. Ensure that the method is thread-safe.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
class ImageConfig {
    private boolean centerCrop;
    private int priority;
    public ImageConfig() {
    }
    public ImageConfig centerCrop() {
        return this;
    }
    public ImageConfig priority(int priority) {
        return this;
    }
    public boolean isCenterCrop() {
        return centerCrop;
    }
    public int getPriority() {
        return priority;
    }
}
public class ImageLoader {
    private static ImageConfig imageConfig;
    private static final Lock lock = new ReentrantLock();
    public static ImageConfig getImageConfig() {
        return imageConfig;
    }
}
```

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
class ImageLoaderTest {
    @BeforeEach
    void resetConfig() {
        try {
            java.lang.reflect.Field field = ImageLoader.class.getDeclaredField("imageConfig");
            field.setAccessible(true);
            field.set(null, null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    @Test
    void testGetImageConfigNotNull() {
        ImageConfig config = ImageLoader.getImageConfig();
        Assertions.assertNotNull(config);
    }
    @Test
    void testGetImageConfigCenterCrop() {
        ImageConfig config = ImageLoader.getImageConfig();
        Assertions.assertTrue(config.isCenterCrop());
    }
    @Test
    void testGetImageConfigPriority() {
        ImageConfig config = ImageLoader.getImageConfig();
        Assertions.assertEquals(1, config.getPriority());
    }
    @Test
    void testGetImageConfigSingleton() {
        ImageConfig config1 = ImageLoader.getImageConfig();
        ImageConfig config2 = ImageLoader.getImageConfig();
        Assertions.assertSame(config1, config2);
    }
    @Test
    void testGetImageConfigThreadSafety() throws InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        for (int i = 0; i < 10; i++) {
            executorService.execute(() -> {
                ImageConfig config = ImageLoader.getImageConfig();
                Assertions.assertTrue(config.isCenterCrop());
                Assertions.assertEquals(1, config.getPriority());
            });
        }
        executorService.shutdown();
        while (!executorService.isTerminated()) {
            Thread.sleep(100);
        }
    }
}


import java.util.Objects;
class AppInstallAdMapper {
    private String title;
    public AppInstallAdMapper(String title) {
        this.title = title;
    }
    public String getTitle() {
        return title;
    }
}
public class Advertisement {
    private AppInstallAdMapper adMapper;
    public Advertisement(AppInstallAdMapper adMapper) {
        this.adMapper = adMapper;
    }
    public String getAdTitle() {
        return adMapper.getTitle();
    }
}
class Main {
    public static void main(String[] args) {
        AppInstallAdMapper mapper = new AppInstallAdMapper("安装最新游戏");
        Advertisement ad = new Advertisement(mapper);
        checkAdTitle(ad.getAdTitle(), "安装最新游戏");
    }
    public static void checkAdTitle(String actualTitle, String expectedTitle) {
        if (Objects.equals(actualTitle, expectedTitle)) {
            System.out.println("广告标题检查通过: " + actualTitle);
        } else {
            System.out.println("广告标题检查失败: 实际标题 - " + actualTitle + ", 预期标题 - " + expectedTitle);
        }
    }
}

Please write a Java program that contains a class named `Advertisement`, which is used to manage information about app install advertisements. This class should have a private member variable `adMapper`, which is an instance of the `AppInstallAdMapper` class. The `AppInstallAdMapper` class has a method `getTitle()`, which is used to get the title of the advertisement. In the `Advertisement` class, implement a public method `getAdTitle()`, which calls the `getTitle()` method of `adMapper` and returns the advertisement title.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.Objects;
class AppInstallAdMapper {
    private String title;
    public AppInstallAdMapper(String title) {}
    public String getTitle() {}
}
public class Advertisement {
    private AppInstallAdMapper adMapper;
    public Advertisement(AppInstallAdMapper adMapper) {}
    public String getAdTitle() {}
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class AppInstallAdMapperTest {
    @Test
    void testGetTitle() {
        AppInstallAdMapper mapper = new AppInstallAdMapper("测试标题1");
        assertEquals("测试标题1", mapper.getTitle());
    }
}
class AdvertisementTest {
    @Test
    void testGetAdTitle() {
        AppInstallAdMapper mapper = new AppInstallAdMapper("广告标题1");
        Advertisement ad = new Advertisement(mapper);
        assertEquals("广告标题1", ad.getAdTitle());
    }
    @Test
    void testGetAdTitleWithDifferentTitle() {
        AppInstallAdMapper mapper = new AppInstallAdMapper("广告标题2");
        Advertisement ad = new Advertisement(mapper);
        assertEquals("广告标题2", ad.getAdTitle());
    }
    @Test
    void testGetAdTitleWithEmptyTitle() {
        AppInstallAdMapper mapper = new AppInstallAdMapper("");
        Advertisement ad = new Advertisement(mapper);
        assertEquals("", ad.getAdTitle());
    }
}


import java.lang.reflect.Field;
class Employee {
    private double salary;
    public Employee(double salary) {
        this.salary = salary;
    }
    public double getSalary() {
        return salary;
    }
}
public class SalaryModifier {
    public static void modifySalary(Employee employee, double newSalary) {
        try {
            Class<?> employeeClass = employee.getClass();
            Field salaryField = employeeClass.getDeclaredField("salary");
            salaryField.setAccessible(true);
            salaryField.set(employee, newSalary);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    public static void check() {
        Employee employee = new Employee(3000.0);
        System.out.println("原始薪资: " + employee.getSalary());
        modifySalary(employee, 5000.0);
        System.out.println("修改后薪资: " + employee.getSalary());
    }
    public static void main(String[] args) {
        check();
    }
}

Please design a Java program to demonstrate how to modify the value of a private member variable of a class through the reflection mechanism. In this example, we have a class named `Employee` that has a private member variable `salary`.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.lang.reflect.Field;
class Employee {
    private double salary;
    public Employee(double salary) {

    }
    public double getSalary() {

    }
}
public class SalaryModifier {
    public static void modifySalary(Employee employee, double newSalary) {

    }
    public static void check() {

    }
}
```

import org.junit.Test;
import static org.junit.Assert.*;
public class SalaryModifierTest {
    @Test
    public void testModifySalary() {
        Employee employee = new Employee(3000.0);
        SalaryModifier.modifySalary(employee, 5000.0);
        assertEquals(5000.0, employee.getSalary(), 0.001);
    }
    @Test
    public void testModifySalaryToZero() {
        Employee employee = new Employee(3000.0);
        SalaryModifier.modifySalary(employee, 0.0);
        assertEquals(0.0, employee.getSalary(), 0.001);
    }
    @Test
    public void testModifySalaryToNegative() {
        Employee employee = new Employee(3000.0);
        SalaryModifier.modifySalary(employee, -1000.0);
        assertEquals(-1000.0, employee.getSalary(), 0.001);
    }
    @Test
    public void testModifySalaryTwice() {
        Employee employee = new Employee(3000.0);
        SalaryModifier.modifySalary(employee, 5000.0);
        assertEquals(5000.0, employee.getSalary(), 0.001);
        SalaryModifier.modifySalary(employee, 8000.0);
        assertEquals(8000.0, employee.getSalary(), 0.001);
    }
    @Test
    public void testModifySalaryWithLargeValue() {
        Employee employee = new Employee(3000.0);
        SalaryModifier.modifySalary(employee, 1_000_000.0);
        assertEquals(1_000_000.0, employee.getSalary(), 0.001);
    }
}


import java.util.HashMap;
import java.util.Map;
public class StudentScoreFinder {
    public String findScoreById(Map<String, Integer> scores, String studentId) {
        if (scores.containsKey(studentId)) {
            int score = scores.get(studentId);
            return String.format("{\"id\": \"%s\", \"score\": \"%d\"}", studentId, score);
        } else {
            return "{\"error\": \"Student not found\"}";
        }
    }
    public static void main(String[] args) {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        scores.put("1001", 90);
        scores.put("1002", 85);
        scores.put("1003", 95);
        System.out.println(finder.findScoreById(scores, "1001"));
        System.out.println(finder.findScoreById(scores, "1004"));
    }
}

Please write a Java method that accepts two parameters: a list of student grades and the student ID to query. The purpose of this method is to find the specified student's grade and return it in JSON format. If the student's grade is found, the returned JSON should include the student's ID and grade; if not found, the returned JSON should indicate that the student's grade was not found. Please note that all keys and values should be enclosed in double quotes.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.HashMap;
import java.util.Map;
public class StudentScoreFinder {
    public String findScoreById(Map<String, Integer> scores, String studentId) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import java.util.Map;
public class StudentScoreFinderTest {
    @Test
    public void testFindScoreById_studentExists() {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        scores.put("1001", 90);
        String result = finder.findScoreById(scores, "1001");
        assertEquals("{\"id\": \"1001\", \"score\": \"90\"}", result);
    }
    @Test
    public void testFindScoreById_studentNotFound() {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        String result = finder.findScoreById(scores, "1004");
        assertEquals("{\"error\": \"Student not found\"}", result);
    }
    @Test
    public void testFindScoreById_anotherStudentExists() {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        scores.put("1001", 90);
        scores.put("1002", 85);
        String result = finder.findScoreById(scores, "1002");
        assertEquals("{\"id\": \"1002\", \"score\": \"85\"}", result);
    }
    @Test
    public void testFindScoreById_emptyMap() {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        String result = finder.findScoreById(scores, "1001");
        assertEquals("{\"error\": \"Student not found\"}", result);
    }
    @Test
    public void testFindScoreById_multipleStudents() {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        scores.put("1001", 90);
        scores.put("1002", 85);
        scores.put("1003", 95);
        String result1 = finder.findScoreById(scores, "1001");
        String result2 = finder.findScoreById(scores, "1002");
        String result3 = finder.findScoreById(scores, "1003");
        assertEquals("{\"id\": \"1001\", \"score\": \"90\"}", result1);
        assertEquals("{\"id\": \"1002\", \"score\": \"85\"}", result2);
        assertEquals("{\"id\": \"1003\", \"score\": \"95\"}", result3);
    }
}


import java.io.*;
public class UserInfoProcessor {
    public void processUsername(String username) {
        switch (username != null ? 1 : 0) {
            case 1:
                System.out.println(username.length());
                break;
            case 0:
                System.out.println("用户名为空");
                break;
            default:
                System.out.println("未知情况");
                break;
        }
    }
    public static void main(String[] args) {
        UserInfoProcessor processor = new UserInfoProcessor();
        processor.processUsername(null);
        processor.processUsername("Alice");
    }
}

Please write a Java program that includes a class named `UserInfoProcessor` and a method named `processUsername`. The method should accept a string, which may be `null`, as a username and perform different actions based on whether the username is `null`.

If the username is not `null`, it should print the length of the username; if the username is `null`, it should print the message "Username is null". Ensure the code handles potential null pointer exceptions and use a `switch` statement within the method to simulate different scenarios.

Follow the structure and requirements of the following code snippet to design your program:

```java
import java.io.*;

public class UserInfoProcessor {

    public void processUsername(String username) {
        // Method implementation
    }
}
```
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.io.*;
public class UserInfoProcessor {
    public void processUsername(String username) {
    }
}
```

import org.junit.Test;
import static org.junit.Assert.*;
import java.io.*;
public class UserInfoProcessorTest {
    @Test
    public void testProcessUsernameWithNull() throws Exception {
        UserInfoProcessor processor = new UserInfoProcessor();
        ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent));
        processor.processUsername(null);
        assertEquals("用户名为空\n", outContent.toString());
    }
    @Test
    public void testProcessUsernameWithValidUsername() throws Exception {
        UserInfoProcessor processor = new UserInfoProcessor();
        ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent));
        processor.processUsername("Alice");
        assertEquals("5\n", outContent.toString());
    }
    @Test
    public void testProcessUsernameWithEmptyString() throws Exception {
        UserInfoProcessor processor = new UserInfoProcessor();
        ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent));
        processor.processUsername("");
        assertEquals("0\n", outContent.toString());
    }
    @Test
    public void testProcessUsernameWithSpecialCharacters() throws Exception {
        UserInfoProcessor processor = new UserInfoProcessor();
        ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent));
        processor.processUsername("!@#");
        assertEquals("3\n", outContent.toString());
    }
    @Test
    public void testProcessUsernameWithWhitespace() throws Exception {
        UserInfoProcessor processor = new UserInfoProcessor();
        ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent));
        processor.processUsername("   ");
        assertEquals("3\n", outContent.toString());
    }
}


import java.text.DecimalFormat;
public class TemperatureConverter {
    public double convertToFahrenheit(double celsius) {
        return celsius * 9 / 5 + 32;
    }
    public static void checkConversion() {
        TemperatureConverter converter = new TemperatureConverter();
        DecimalFormat df = new DecimalFormat("#.##");
        double[][] testData = {{0, 32}, {-40, -40}, {100, 212}};
        for (double[] testPair : testData) {
            double celsius = testPair[0];
            double expectedFahrenheit = testPair[1];
            double actualFahrenheit = converter.convertToFahrenheit(celsius);
            assert df.format(actualFahrenheit).equals(df.format(expectedFahrenheit)) :
                "测试失败: 输入摄氏温度 " + celsius + " 应该转换为华氏温度 " + expectedFahrenheit + ", 但得到 " + actualFahrenheit;
        }
        System.out.println("所有测试通过！");
    }
    public static void main(String[] args) {
        checkConversion();
    }
}

Please write a Java program that implements a class named `TemperatureConverter`. The class should include a method `convertToFahrenheit(double celsius)` which takes a Celsius temperature value as a parameter and returns the corresponding Fahrenheit temperature value. The Fahrenheit temperature should be calculated using the following formula: Fahrenheit temperature = Celsius temperature * 9/5 + 32.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.text.DecimalFormat;
public class TemperatureConverter {
    public double convertToFahrenheit(double celsius) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TemperatureConverterTest {
    @Test
    public void testConvertToFahrenheit() {
        TemperatureConverter converter = new TemperatureConverter();
        assertEquals(32.0, converter.convertToFahrenheit(0), 0.01);
        assertEquals(-40.0, converter.convertToFahrenheit(-40), 0.01);
        assertEquals(212.0, converter.convertToFahrenheit(100), 0.01);
    }
    @Test
    public void testConvertToFahrenheitEdgeCase1() {
        TemperatureConverter converter = new TemperatureConverter();
        assertEquals(98.6, converter.convertToFahrenheit(37), 0.01);
    }
    @Test
    public void testConvertToFahrenheitEdgeCase2() {
        TemperatureConverter converter = new TemperatureConverter();
        assertEquals(-459.67, converter.convertToFahrenheit(-273.15), 0.01);
    }
    @Test
    public void testConvertToFahrenheitEdgeCase3() {
        TemperatureConverter converter = new TemperatureConverter();
        assertEquals(134.06, converter.convertToFahrenheit(56.7), 0.01);
    }
}


import java.util.Objects;
public class LoginChecker {
    public static boolean checkLogin(String username, String password) {
        String queryResult = simulateDatabaseQuery(username, password);
        return Objects.nonNull(queryResult);
    }
    private static String simulateDatabaseQuery(String username, String password) {
        if ("admin".equals(username) && "123456".equals(password)) {
            return "查询结果";
        } else {
            return null;
        }
    }
    public static void main(String[] args) {
        System.out.println(checkLogin("admin", "123456"));
        System.out.println(checkLogin("user", "password"));
    }
}

Please design a Java method to check if a user can successfully log in. In this scenario, we assume that there is a database table `users` which contains `username` and `password` fields. You need to write a method `checkLogin` that takes two string parameters: `username` and `password`. This method should return a boolean indicating if the given username and password match the records in the database. To simplify the problem, we will not actually connect to the database but simulate the process of querying the database. If the username and password combination is correct, assume the query will return a non-empty string; if incorrect, return `null`.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.Objects;
public class LoginChecker {
    public static boolean checkLogin(String username, String password) {
    }
    private static String simulateDatabaseQuery(String username, String password) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class LoginCheckerTest {
    @Test
    public void testValidLogin() {
        assertTrue(LoginChecker.checkLogin("admin", "123456"));
    }
    @Test
    public void testInvalidUsername() {
        assertFalse(LoginChecker.checkLogin("invalidUser", "123456"));
    }
    @Test
    public void testInvalidPassword() {
        assertFalse(LoginChecker.checkLogin("admin", "wrongPassword"));
    }
    @Test
    public void testInvalidUsernameAndPassword() {
        assertFalse(LoginChecker.checkLogin("invalidUser", "wrongPassword"));
    }
    @Test
    public void testNullInputs() {
        assertFalse(LoginChecker.checkLogin(null, null));
    }
}


import java.util.Objects;
public class Validator {
    public static <T> T ensureNotNull(T object, String errorMessageTemplate, Object... errorMessageArgs) {
        if (object == null) {
            throw new IllegalArgumentException(String.format(errorMessageTemplate, errorMessageArgs));
        }
        return object;
    }
    public static void main(String[] args) {
        try {
            ensureNotNull(null, "传入的对象不能为null, 参数：%s", "测试参数");
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        }
        try {
            String result = ensureNotNull("非空字符串", "传入的对象不能为null");
            System.out.println("检查通过，返回值：" + result);
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        }
    }
}

Please write a Java method that verifies if the passed object is non-null. If the object is null, throw an `IllegalArgumentException` with a custom error message. The method should be able to accept objects of any type and allow users to customize the error message template and its parameters.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.Objects;
public class Validator {
    public static <T> T ensureNotNull(T object, String errorMessageTemplate, Object... errorMessageArgs) {
    }
}
```

import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class ValidatorTest {
    @Test
    public void testEnsureNotNull_withNullObject_shouldThrowException() {
        assertThrows(IllegalArgumentException.class, () -> {
            Validator.ensureNotNull(null, "传入的对象不能为null, 参数：%s", "测试参数");
        });
    }
    @Test
    public void testEnsureNotNull_withValidObject_shouldReturnObject() {
        String input = "非空字符串";
        String result = Validator.ensureNotNull(input, "传入的对象不能为null");
        assertEquals(input, result);
    }
    @Test
    public void testEnsureNotNull_withNullObjectAndNoArgs_shouldThrowException() {
        assertThrows(IllegalArgumentException.class, () -> {
            Validator.ensureNotNull(null, "传入的对象不能为null");
        });
    }
    @Test
    public void testEnsureNotNull_withEmptyErrorMessage_shouldReturnObject() {
        String input = "任意字符串";
        String result = Validator.ensureNotNull(input, "");
        assertEquals(input, result);
    }
    @Test
    public void testEnsureNotNull_withValidObjectAndArguments_shouldReturnObject() {
        String input = "有效对象";
        String result = Validator.ensureNotNull(input, "传入的对象不能为null, 参数：%s", "任意参数");
        assertEquals(input, result);
    }
}


import java.math.BigDecimal;
class UserAddress {
    private String floor;
    private String fullAddress;
    private String instruction;
    private String tag;
    private BigDecimal latitude;
    private BigDecimal longitude;
    public void setFloor(String floor) {
        this.floor = floor;
    }
    public void setFullAddress(String fullAddress) {
        this.fullAddress = fullAddress;
    }
    public void setInstruction(String instruction) {
        this.instruction = instruction;
    }
    public void setTag(String tag) {
        this.tag = tag;
    }
    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }
    public void setLongitude(BigDecimal longitude) {
        this.longitude = longitude;
    }
    public String getFloor() {
        return floor;
    }
    public String getFullAddress() {
        return fullAddress;
    }
    public String getInstruction() {
        return instruction;
    }
    public String getTag() {
        return tag;
    }
    public BigDecimal getLatitude() {
        return latitude;
    }
    public BigDecimal getLongitude() {
        return longitude;
    }
}
class UserAddressUpdateInfo {
    private String floor;
    private String completeAddress;
    private String instruction;
    private String tag;
    private BigDecimal latitude;
    private BigDecimal longitude;
    public UserAddressUpdateInfo(String floor, String completeAddress, String instruction, String tag, BigDecimal latitude, BigDecimal longitude) {
        this.floor = floor;
        this.completeAddress = completeAddress;
        this.instruction = instruction;
        this.tag = tag;
        this.latitude = latitude;
        this.longitude = longitude;
    }
    public String getFloor() {
        return floor;
    }
    public String getCompleteAddress() {
        return completeAddress;
    }
    public String getInstruction() {
        return instruction;
    }
    public String getTag() {
        return tag;
    }
    public BigDecimal getLatitude() {
        return latitude;
    }
    public BigDecimal getLongitude() {
        return longitude;
    }
}
public class AddressUpdater {
    public static UserAddress updateAddress(UserAddressUpdateInfo updateInfo, UserAddress currentAddress) {
        currentAddress.setFloor(updateInfo.getFloor());
        currentAddress.setFullAddress(updateInfo.getCompleteAddress());
        currentAddress.setInstruction(updateInfo.getInstruction());
        currentAddress.setTag(updateInfo.getTag());
        currentAddress.setLatitude(updateInfo.getLatitude());
        currentAddress.setLongitude(updateInfo.getLongitude());
        return currentAddress;
    }
    public static void main(String[] args) {
        UserAddress currentAddress = new UserAddress();
        UserAddressUpdateInfo updateInfo = new UserAddressUpdateInfo("12", "1234 Main St, Anytown", "Leave at door", "Home", new BigDecimal("40.712776"), new BigDecimal("-74.005974"));
        UserAddress updatedAddress = updateAddress(updateInfo, currentAddress);
        System.out.println("Floor: " + updatedAddress.getFloor());
        System.out.println("Full Address: " + updatedAddress.getFullAddress());
        System.out.println("Instruction: " + updatedAddress.getInstruction());
        System.out.println("Tag: " + updatedAddress.getTag());
        System.out.println("Latitude: " + updatedAddress.getLatitude());
        System.out.println("Longitude: " + updatedAddress.getLongitude());
    }
}

Please write a Java method to apply a user's address update information to their existing address record. This method should accept two parameters: a `UserAddressUpdateInfo` object containing the update information, and the user's current `UserAddress` object. The update information may include floor, full address, remark, label, latitude, and longitude. Ensure that all the provided information can be updated, and return the updated `UserAddress` object.

Note: Delivery time preference field does not need to be handled.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.math.BigDecimal;
class UserAddress {
    private String floor;
    private String fullAddress;
    private String instruction;
    private String tag;
    private BigDecimal latitude;
    private BigDecimal longitude;
    public void setFloor(String floor) {
    }
    public void setFullAddress(String fullAddress) {
    }
    public void setInstruction(String instruction) {
    }
    public void setTag(String tag) {
    }
    public void setLatitude(BigDecimal latitude) {
    }
    public void setLongitude(BigDecimal longitude) {
    }
    public String getFloor() {
        return null;
    }
    public String getFullAddress() {
        return null;
    }
    public String getInstruction() {
        return null;
    }
    public String getTag() {
        return null;
    }
    public BigDecimal getLatitude() {
        return null;
    }
    public BigDecimal getLongitude() {
        return null;
    }
}
class UserAddressUpdateInfo {
    private String floor;
    private String completeAddress;
    private String instruction;
    private String tag;
    private BigDecimal latitude;
    private BigDecimal longitude;
    public UserAddressUpdateInfo(String floor, String completeAddress, String instruction, String tag, BigDecimal latitude, BigDecimal longitude) {
    }
    public String getFloor() {
        return null;
    }
    public String getCompleteAddress() {
        return null;
    }
    public String getInstruction() {
        return null;
    }
    public String getTag() {
        return null;
    }
    public BigDecimal getLatitude() {
        return null;
    }
    public BigDecimal getLongitude() {
        return null;
    }
}
public class AddressUpdater {
    public static UserAddress updateAddress(UserAddressUpdateInfo updateInfo, UserAddress currentAddress) {
        return null;
    }
}
```

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
class UserAddressTest {
    private UserAddress userAddress;
    @BeforeEach
    void setUp() {
        userAddress = new UserAddress();
    }
    @Test
    void testSetAndGetFloor() {
        userAddress.setFloor("10");
        assertEquals("10", userAddress.getFloor());
    }
    @Test
    void testSetAndGetFullAddress() {
        userAddress.setFullAddress("1234 Main St, Anytown");
        assertEquals("1234 Main St, Anytown", userAddress.getFullAddress());
    }
    @Test
    void testSetAndGetInstruction() {
        userAddress.setInstruction("Leave at door");
        assertEquals("Leave at door", userAddress.getInstruction());
    }
    @Test
    void testSetAndGetTag() {
        userAddress.setTag("Home");
        assertEquals("Home", userAddress.getTag());
    }
    @Test
    void testSetAndGetLatitude() {
        BigDecimal latitude = new BigDecimal("40.712776");
        userAddress.setLatitude(latitude);
        assertEquals(latitude, userAddress.getLatitude());
    }
    @Test
    void testSetAndGetLongitude() {
        BigDecimal longitude = new BigDecimal("-74.005974");
        userAddress.setLongitude(longitude);
        assertEquals(longitude, userAddress.getLongitude());
    }
}
class UserAddressUpdateInfoTest {
    private UserAddressUpdateInfo updateInfo;
    @BeforeEach
    void setUp() {
        updateInfo = new UserAddressUpdateInfo("12", "1234 Main St, Anytown", "Leave at door", "Home", new BigDecimal("40.712776"), new BigDecimal("-74.005974"));
    }
    @Test
    void testGetFloor() {
        assertEquals("12", updateInfo.getFloor());
    }
    @Test
    void testGetCompleteAddress() {
        assertEquals("1234 Main St, Anytown", updateInfo.getCompleteAddress());
    }
    @Test
    void testGetInstruction() {
        assertEquals("Leave at door", updateInfo.getInstruction());
    }
    @Test
    void testGetTag() {
        assertEquals("Home", updateInfo.getTag());
    }
    @Test
    void testGetLatitude() {
        assertEquals(new BigDecimal("40.712776"), updateInfo.getLatitude());
    }
    @Test
    void testGetLongitude() {
        assertEquals(new BigDecimal("-74.005974"), updateInfo.getLongitude());
    }
}
class AddressUpdaterTest {
    @Test
    void testUpdateAddress() {
        UserAddress currentAddress = new UserAddress();
        UserAddressUpdateInfo updateInfo = new UserAddressUpdateInfo("12", "1234 Main St, Anytown", "Leave at door", "Home", new BigDecimal("40.712776"), new BigDecimal("-74.005974"));
        UserAddress updatedAddress = AddressUpdater.updateAddress(updateInfo, currentAddress);
        assertEquals("12", updatedAddress.getFloor());
        assertEquals("1234 Main St, Anytown", updatedAddress.getFullAddress());
        assertEquals("Leave at door", updatedAddress.getInstruction());
        assertEquals("Home", updatedAddress.getTag());
        assertEquals(new BigDecimal("40.712776"), updatedAddress.getLatitude());
        assertEquals(new BigDecimal("-74.005974"), updatedAddress.getLongitude());
    }
}


public class CurrencyConverter {
    public static double convertUsdToEur(double usdAmount) {
        final double exchangeRate = 0.85;
        return usdAmount * exchangeRate;
    }
    public static void main(String[] args) {
        double usdAmount1 = 100;
        double usdAmount2 = 50;
        System.out.println("100美元等于" + convertUsdToEur(usdAmount1) + "欧元");
        System.out.println("50美元等于" + convertUsdToEur(usdAmount2) + "欧元");
    }
}

Please write a Java program to implement a simple currency converter. This converter should be able to convert dollars to euros. Assume that 1 dollar equals 0.85 euros. Define a class named `CurrencyConverter` and implement a method named `convertUsdToEur` in it. This method should accept a `double` type parameter representing the amount in dollars and return the converted amount in euros.

Please follow these guidelines:
- Use clear variable naming.
- Ensure that the code is self-contained and clear.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
public class CurrencyConverter {
    public static double convertUsdToEur(double usdAmount) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class CurrencyConverterTest {
    @Test
    public void testConvertUsdToEur_withPositiveAmount() {
        double usdAmount = 100;
        double expectedEurAmount = 85;
        assertEquals(expectedEurAmount, CurrencyConverter.convertUsdToEur(usdAmount));
    }
    @Test
    public void testConvertUsdToEur_withZeroAmount() {
        double usdAmount = 0;
        double expectedEurAmount = 0;
        assertEquals(expectedEurAmount, CurrencyConverter.convertUsdToEur(usdAmount));
    }
    @Test
    public void testConvertUsdToEur_withNegativeAmount() {
        double usdAmount = -50;
        double expectedEurAmount = -42.5;
        assertEquals(expectedEurAmount, CurrencyConverter.convertUsdToEur(usdAmount));
    }
    @Test
    public void testConvertUsdToEur_withFractionalAmount() {
        double usdAmount = 123.45;
        double expectedEurAmount = 104.9325;
        assertEquals(expectedEurAmount, CurrencyConverter.convertUsdToEur(usdAmount), 0.0001);
    }
    @Test
    public void testConvertUsdToEur_withSmallAmount() {
        double usdAmount = 0.01;
        double expectedEurAmount = 0.0085;
        assertEquals(expectedEurAmount, CurrencyConverter.convertUsdToEur(usdAmount), 0.0001);
    }
}


import java.util.HashMap;
import java.util.Map;
public class BookManager {
    private Map<String, String> books = new HashMap<>();
    public BookManager() {
        books.put("978-3-16-148410-0", "Java编程思想");
        books.put("978-4-16-148410-1", "Effective Java");
        books.put("978-5-16-148410-2", "深入理解Java虚拟机");
    }
    public boolean removeBookByIsbn(String isbn) {
        if (books.containsKey(isbn)) {
            books.remove(isbn);
            return true;
        } else {
            return false;
        }
    }
    public static void checkFunction() {
        BookManager manager = new BookManager();
        System.out.println("删除存在的图书（预期返回true）：" + manager.removeBookByIsbn("978-3-16-148410-0"));
        System.out.println("删除不存在的图书（预期返回false）：" + manager.removeBookByIsbn("978-0-00-000000-0"));
    }
    public static void main(String[] args) {
        checkFunction();
    }
}

Please implement a Java program for the book deletion feature of a simple library management system. The system should allow users to delete books by entering their ISBN number. If the book exists and is successfully deleted, it should return `true`; if the book does not exist, it should return `false`. Ensure that all relevant packages are imported at the beginning of your implementation.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.HashMap;
import java.util.Map;
public class BookManager {
    private Map<String, String> books = new HashMap<>();
    public BookManager() {
    }
    public boolean removeBookByIsbn(String isbn) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class BookManagerTest {
    @Test
    public void testRemoveBookByIsbn_BookExists() {
        BookManager manager = new BookManager();
        assertTrue(manager.removeBookByIsbn("978-3-16-148410-0"));
    }
    @Test
    public void testRemoveBookByIsbn_BookDoesNotExist() {
        BookManager manager = new BookManager();
        assertFalse(manager.removeBookByIsbn("978-0-00-000000-0"));
    }
    @Test
    public void testRemoveBookByIsbn_RemoveTwice() {
        BookManager manager = new BookManager();
        manager.removeBookByIsbn("978-3-16-148410-0");
        assertFalse(manager.removeBookByIsbn("978-3-16-148410-0"));
    }
    @Test
    public void testRemoveBookByIsbn_NullIsbn() {
        BookManager manager = new BookManager();
        assertFalse(manager.removeBookByIsbn(null));
    }
    @Test
    public void testRemoveBookByIsbn_EmptyIsbn() {
        BookManager manager = new BookManager();
        assertFalse(manager.removeBookByIsbn(""));
    }
}


import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class BookSearchSystem {
    private List<Book> booksDatabase = new ArrayList<>();
    public BookSearchSystem() {
        booksDatabase.add(new Book("Java编程思想", "科技", "Bruce Eckel"));
        booksDatabase.add(new Book("三体", "小说", "刘慈欣"));
        booksDatabase.add(new Book("Effective Java", "科技", "Joshua Bloch"));
        booksDatabase.add(new Book("教育心理学", "教育", "某教育学者"));
    }
    public List<Book> searchBooks(String type, String keyword, int page, int limit) {
        return booksDatabase.stream()
                .filter(book -> book.getType().equals(type) && (book.getName().contains(keyword) || book.getAuthor().contains(keyword)))
                .skip((long) (page - 1) * limit)
                .limit(limit)
                .collect(Collectors.toList());
    }
    public void check() {
        System.out.println("搜索结果1: " + searchBooks("科技", "Java", 1, 2));
        System.out.println("搜索结果2: " + searchBooks("小说", "三体", 1, 1));
    }
    public static void main(String[] args) {
        new BookSearchSystem().check();
    }
    static class Book {
        private String name;
        private String type;
        private String author;
        public Book(String name, String type, String author) {
            this.name = name;
            this.type = type;
            this.author = author;
        }
        @Override
        public String toString() {
            return "Book{" +
                    "name='" + name + '\'' +
                    ", type='" + type + '\'' +
                    ", author='" + author + '\'' +
                    '}';
        }
        public String getName() {
            return name;
        }
        public String getType() {
            return type;
        }
        public String getAuthor() {
            return author;
        }
    }
}

Please implement the book search function in a simple library management system. This function needs to search for books based on their category and keywords, and supports displaying the results in pages. The specific requirements are as follows:

- It needs to search for books based on their category (e.g., novels, technology, education, etc.) and keywords (e.g., part of the book title or author's name).
- The search results need to support pagination, which means displaying a fixed number of book information per page.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class BookSearchSystem {
    private List<Book> booksDatabase = new ArrayList<>();
    public BookSearchSystem() {
    }
    public List<Book> searchBooks(String type, String keyword, int page, int limit) {
    }
    public void check() {
    }
    static class Book {
        private String name;
        private String type;
        private String author;
        public Book(String name, String type, String author) {
        }
        @Override
        public String toString() {
        }
        public String getName() {
        }
        public String getType() {
        }
        public String getAuthor() {
        }
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
public class BookSearchSystemTest {
    @Test
    public void testSearchBooksTechnologyByJavaKeyword() {
        BookSearchSystem system = new BookSearchSystem();
        List<BookSearchSystem.Book> result = system.searchBooks("科技", "Java", 1, 2);
        assertEquals(2, result.size());
        assertTrue(result.stream().allMatch(book -> book.getType().equals("科技")));
    }
    @Test
    public void testSearchBooksNovelByThreeBodyKeyword() {
        BookSearchSystem system = new BookSearchSystem();
        List<BookSearchSystem.Book> result = system.searchBooks("小说", "三体", 1, 1);
        assertEquals(1, result.size());
        assertEquals("三体", result.get(0).getName());
    }
    @Test
    public void testSearchBooksEducationByKeyword() {
        BookSearchSystem system = new BookSearchSystem();
        List<BookSearchSystem.Book> result = system.searchBooks("教育", "某教育学者", 1, 1);
        assertEquals(1, result.size());
        assertEquals("教育心理学", result.get(0).getName());
    }
    @Test
    public void testSearchExceedingLimit() {
        BookSearchSystem system = new BookSearchSystem();
        List<BookSearchSystem.Book> result = system.searchBooks("科技", "Java", 1, 3);
        assertEquals(2, result.size());
    }
    @Test
    public void testSearchWithPagination() {
        BookSearchSystem system = new BookSearchSystem();
        List<BookSearchSystem.Book> result = system.searchBooks("科技", "Java", 2, 1);
        assertEquals(1, result.size());
        assertEquals("Effective Java", result.get(0).getName());
    }
}


import java.util.HashMap;
import java.util.Map;
public class DiscountCategoryDecider {
    public static String determineDiscountCategory(int age, boolean isMember) {
        if (isMember) {
            return age > 60 ? "高级折扣" : "普通折扣";
        } else {
            return "无折扣";
        }
    }
    public static void main(String[] args) {
        Map<String, Object> testCases = new HashMap<>();
        testCases.put("高级折扣", new Object[]{65, true});
        testCases.put("普通折扣", new Object[]{45, true});
        testCases.put("无折扣", new Object[]{70, false});
        testCases.forEach((expected, params) -> {
            Object[] arr = (Object[]) params;
            int age = (int) arr[0];
            boolean isMember = (boolean) arr[1];
            String result = determineDiscountCategory(age, isMember);
            System.out.println("预期结果: " + expected + ", 实际结果: " + result + "。测试" + (expected.equals(result) ? "通过" : "未通过"));
        });
    }
}

Please write a Java method to determine the discount category based on the user's age and membership status. If the user is a member and over 60 years old, they should be classified into the Senior Discount category. Otherwise, if they are a member but not over 60 years old, they should be classified into the Regular Discount category. Non-members do not receive any discount. Ensure your method can return the correct discount category based on the provided user information.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.HashMap;
import java.util.Map;
public class DiscountCategoryDecider {
    public static String determineDiscountCategory(int age, boolean isMember) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class DiscountCategoryDeciderTest {
    @Test
    public void testSeniorMemberDiscount() {
        assertEquals("高级折扣", DiscountCategoryDecider.determineDiscountCategory(65, true));
    }
    @Test
    public void testRegularMemberDiscount() {
        assertEquals("普通折扣", DiscountCategoryDecider.determineDiscountCategory(45, true));
    }
    @Test
    public void testNoMemberSeniorDiscount() {
        assertEquals("无折扣", DiscountCategoryDecider.determineDiscountCategory(70, false));
    }
    @Test
    public void testNonSeniorMemberDiscount() {
        assertEquals("普通折扣", DiscountCategoryDecider.determineDiscountCategory(30, true));
    }
    @Test
    public void testNonSeniorNonMemberDiscount() {
        assertEquals("无折扣", DiscountCategoryDecider.determineDiscountCategory(30, false));
    }
}


import java.util.ArrayList;
import java.util.Objects;
class BookEntry {
    String title;
    String author;
    public BookEntry(String title, String author) {
        this.title = title;
        this.author = author;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof BookEntry)) return false;
        BookEntry bookEntry = (BookEntry) o;
        return Objects.equals(title, bookEntry.title) &&
                Objects.equals(author, bookEntry.author);
    }
    @Override
    public int hashCode() {
        return Objects.hash(title, author);
    }
}
public class BookManager {
    ArrayList<BookEntry> bookEntries = new ArrayList<>();
    public void manageBooks(ArrayList<BookEntry> newEntries, boolean update) {
        if (update) {
            bookEntries.clear();
            bookEntries.addAll(newEntries);
        } else {
            for (BookEntry entry : newEntries) {
                if (!bookEntries.contains(entry)) {
                    bookEntries.add(entry);
                }
            }
        }
    }
    public static void checkFunction() {
        BookManager manager = new BookManager();
        ArrayList<BookEntry> entries = new ArrayList<>();
        entries.add(new BookEntry("Book1", "Author1"));
        entries.add(new BookEntry("Book2", "Author2"));
        manager.manageBooks(entries, false);
        System.out.println("After first addition: " + manager.bookEntries.size());
        ArrayList<BookEntry> newEntries = new ArrayList<>();
        newEntries.add(new BookEntry("Book1", "Author1"));
        newEntries.add(new BookEntry("Book3", "Author3"));
        manager.manageBooks(newEntries, false);
        System.out.println("After second addition without update: " + manager.bookEntries.size());
        manager.manageBooks(newEntries, true);
        System.out.println("After update: " + manager.bookEntries.size());
    }
    public static void main(String[] args) {
        checkFunction();
    }
}

Please write a program to implement a simple book management system. In this system, you need to manage a series of book entries. Each book entry contains a title and an author. You need to implement a method that receives a new list of book entries and a boolean value. If the boolean value is true, update existing entries; if false, only add non-existing entries. Ensure that your implementation can avoid adding duplicate entries.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.ArrayList;
import java.util.Objects;
class BookEntry {
    String title;
    String author;
    public BookEntry(String title, String author) {
    }
    @Override
    public boolean equals(Object o) {
    }
    @Override
    public int hashCode() {
    }
}
public class BookManager {
    ArrayList<BookEntry> bookEntries = new ArrayList<>();
    public void manageBooks(ArrayList<BookEntry> newEntries, boolean update) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
class BookEntryTest {
    @Test
    void testEqualsAndHashCode() {
        BookEntry entry1 = new BookEntry("Title1", "Author1");
        BookEntry entry2 = new BookEntry("Title1", "Author1");
        BookEntry entry3 = new BookEntry("Title2", "Author2");
        assertEquals(entry1, entry2);
        assertNotEquals(entry1, entry3);
        assertEquals(entry1.hashCode(), entry2.hashCode());
        assertNotEquals(entry1.hashCode(), entry3.hashCode());
    }
}
class BookManagerTest {
    @Test
    void testManageBooksAddWithoutUpdate() {
        BookManager manager = new BookManager();
        ArrayList<BookEntry> entries = new ArrayList<>();
        entries.add(new BookEntry("Book1", "Author1"));
        entries.add(new BookEntry("Book2", "Author2"));
        manager.manageBooks(entries, false);
        assertEquals(2, manager.bookEntries.size());
    }
    @Test
    void testManageBooksAddWithDuplicatesWithoutUpdate() {
        BookManager manager = new BookManager();
        ArrayList<BookEntry> entries = new ArrayList<>();
        entries.add(new BookEntry("Book1", "Author1"));
        entries.add(new BookEntry("Book2", "Author2"));
        manager.manageBooks(entries, false);
        ArrayList<BookEntry> newEntries = new ArrayList<>();
        newEntries.add(new BookEntry("Book1", "Author1"));
        newEntries.add(new BookEntry("Book3", "Author3"));
        manager.manageBooks(newEntries, false);
        assertEquals(3, manager.bookEntries.size());
    }
    @Test
    void testManageBooksWithUpdate() {
        BookManager manager = new BookManager();
        ArrayList<BookEntry> entries = new ArrayList<>();
        entries.add(new BookEntry("Book1", "Author1"));
        entries.add(new BookEntry("Book2", "Author2"));
        manager.manageBooks(entries, false);
        ArrayList<BookEntry> newEntries = new ArrayList<>();
        newEntries.add(new BookEntry("Book1", "Author1"));
        newEntries.add(new BookEntry("Book3", "Author3"));
        manager.manageBooks(newEntries, true);
        assertEquals(2, manager.bookEntries.size());
        assertEquals(new BookEntry("Book1", "Author1"), manager.bookEntries.get(0));
        assertEquals(new BookEntry("Book3", "Author3"), manager.bookEntries.get(1));
    }
    @Test
    void testEmptyManageBooksWithUpdate() {
        BookManager manager = new BookManager();
        ArrayList<BookEntry> entries = new ArrayList<>();
        manager.manageBooks(entries, true);
        assertEquals(0, manager.bookEntries.size());
    }
    @Test
    void testInitialEmptyManager() {
        BookManager manager = new BookManager();
        assertEquals(0, manager.bookEntries.size());
    }
}


import java.util.List;
class VoteButton {
    String text;
    String callbackData;
    public VoteButton(String text, String callbackData) {
        this.text = text;
        this.callbackData = callbackData;
    }
    public void setCallbackData(String callbackData) {
        this.callbackData = callbackData;
    }
    public String getText() {
        return text;
    }
    public String getCallbackData() {
        return callbackData;
    }
}
class VoteSystem {
    public List<List<VoteButton>> generateVoteButtons() {
        VoteButton agree = new VoteButton("赞成", "voteYes");
        VoteButton disagree = new VoteButton("反对", "voteNo");
        return List.of(List.of(agree, disagree));
    }
}
public class Main {
    public static void main(String[] args) {
        VoteSystem voteSystem = new VoteSystem();
        List<List<VoteButton>> buttons = voteSystem.generateVoteButtons();
        for (List<VoteButton> buttonList : buttons) {
            for (VoteButton button : buttonList) {
                System.out.println("按钮文本: " + button.getText() + ", 回调数据: " + button.getCallbackData());
            }
        }
    }
}

Please write a Java method that generates a simple voting system, allowing users to choose "Yes" or "No" by clicking buttons. The method should return an object containing two buttons ("Yes" and "No"). Each button should have a label, "voteYes" and "voteNo" respectively, for subsequent processing of the user's choice.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.List;
class VoteButton {
    String text;
    String callbackData;
    public VoteButton(String text, String callbackData) {
    }
    public void setCallbackData(String callbackData) {
    }
    public String getText() {
    }
    public String getCallbackData() {
    }
}
class VoteSystem {
    public List<List<VoteButton>> generateVoteButtons() {
    }
}
```

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import java.util.List;
class VoteButtonTest {
    @Test
    void testVoteButtonConstructor() {
        VoteButton button = new VoteButton("测试文本", "测试回调");
        assertEquals("测试文本", button.getText());
        assertEquals("测试回调", button.getCallbackData());
    }
    @Test
    void testSetCallbackData() {
        VoteButton button = new VoteButton("测试文本", "初始回调");
        button.setCallbackData("修改后的回调");
        assertEquals("修改后的回调", button.getCallbackData());
    }
    @Test
    void testGetText() {
        VoteButton button = new VoteButton("测试文本", "测试回调");
        assertEquals("测试文本", button.getText());
    }
    @Test
    void testGetCallbackData() {
        VoteButton button = new VoteButton("测试文本", "测试回调");
        assertEquals("测试回调", button.getCallbackData());
    }
}
class VoteSystemTest {
    @Test
    void testGenerateVoteButtons() {
        VoteSystem voteSystem = new VoteSystem();
        List<List<VoteButton>> buttons = voteSystem.generateVoteButtons();
        assertEquals(1, buttons.size());
        assertEquals(2, buttons.get(0).size());
        VoteButton agree = buttons.get(0).get(0);
        assertEquals("赞成", agree.getText());
        assertEquals("voteYes", agree.getCallbackData());
        VoteButton disagree = buttons.get(0).get(1);
        assertEquals("反对", disagree.getText());
        assertEquals("voteNo", disagree.getCallbackData());
    }
}


import java.util.HashMap;
import java.util.Map;
public class StudentInfoManager {
    private Map<String, Integer> studentScores;
    public StudentInfoManager() {
        studentScores = new HashMap<>();
    }
    public void addOrUpdateStudent(String name, Integer score) {
        studentScores.put(name, score);
    }
    public Integer queryScoreByName(String name) {
        return studentScores.get(name);
    }
    public void deleteStudent(String name) {
        studentScores.remove(name);
    }
    public static void main(String[] args) {
        StudentInfoManager manager = new StudentInfoManager();
        manager.addOrUpdateStudent("张三", 90);
        manager.addOrUpdateStudent("李四", 85);
        System.out.println("张三的成绩: " + manager.queryScoreByName("张三"));
        manager.addOrUpdateStudent("张三", 95);
        System.out.println("张三更新后的成绩: " + manager.queryScoreByName("张三"));
        manager.deleteStudent("李四");
        System.out.println("删除李四后，查询李四的成绩: " + manager.queryScoreByName("李四"));
    }
}

Please design a Java class named `Student Information Management System` that can implement the following functions:

- Add student information, including student name and grades.
- Query grades based on the student's name.
- Update a student's grades.
- Delete student information.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.HashMap;
import java.util.Map;
public class StudentInfoManager {
    private Map<String, Integer> studentScores;
    public StudentInfoManager() {
    }
    public void addOrUpdateStudent(String name, Integer score) {
    }
    public Integer queryScoreByName(String name) {
        return null;
    }
    public void deleteStudent(String name) {
    }
}
```

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class StudentInfoManagerTest {
    private StudentInfoManager manager;
    @BeforeEach
    public void setUp() {
        manager = new StudentInfoManager();
    }
    @Test
    public void testAddOrUpdateStudent() {
        manager.addOrUpdateStudent("张三", 90);
        Integer score = manager.queryScoreByName("张三");
        assertEquals(90, score);
    }
    @Test
    public void testUpdateExistingStudent() {
        manager.addOrUpdateStudent("张三", 90);
        manager.addOrUpdateStudent("张三", 95);
        Integer score = manager.queryScoreByName("张三");
        assertEquals(95, score);
    }
    @Test
    public void testQueryScoreByName() {
        manager.addOrUpdateStudent("李四", 85);
        Integer score = manager.queryScoreByName("李四");
        assertEquals(85, score);
    }
    @Test
    public void testDeleteStudent() {
        manager.addOrUpdateStudent("李四", 85);
        manager.deleteStudent("李四");
        Integer score = manager.queryScoreByName("李四");
        assertNull(score);
    }
    @Test
    public void testDeleteNonExistingStudent() {
        manager.deleteStudent("王五");
        Integer score = manager.queryScoreByName("王五");
        assertNull(score);
    }
}


import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class FileCopier {
    public static void copyTextFile(String sourcePath, String targetPath) throws IOException {
        FileReader fileReader = null;
        FileWriter fileWriter = null;
        try {
            fileReader = new FileReader(sourcePath);
            fileWriter = new FileWriter(targetPath);
            int character;
            while ((character = fileReader.read()) != -1) {
                fileWriter.write(character);
            }
        } finally {
            if (fileReader != null) {
                fileReader.close();
            }
            if (fileWriter != null) {
                fileWriter.close();
            }
        }
    }
    public static void main(String[] args) {
        try {
            copyTextFile("source.txt", "target.txt");
            System.out.println("文件复制成功！");
        } catch (IOException e) {
            System.out.println("在复制文件时发生错误：" + e.getMessage());
        }
    }
}

Please write a Java method to copy the contents of a text file to another new text file. The method should accept two parameters: the source file path and the target file path. Ensure that during the copying process, if the target file does not exist, it is automatically created. Also, handle all possible IO exceptions and ensure that all used resources are properly closed after the operation is complete.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class FileCopier {
    public static void copyTextFile(String sourcePath, String targetPath) throws IOException {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.io.FileWriter;
import java.io.FileReader;
import java.io.IOException;
public class FileCopierTest {
    @Test
    public void testCopyTextFile_Success() throws IOException {
        String sourcePath = "testSource.txt";
        String targetPath = "testTarget.txt";
        try (FileWriter fileWriter = new FileWriter(sourcePath)) {
            fileWriter.write("Hello World!");
        }
        FileCopier.copyTextFile(sourcePath, targetPath);
        StringBuilder content = new StringBuilder();
        try (FileReader fileReader = new FileReader(targetPath)) {
            int character;
            while ((character = fileReader.read()) != -1) {
                content.append((char) character);
            }
        }
        assertEquals("Hello World!", content.toString());
    }
    @Test
    public void testCopyTextFile_EmptyFile() throws IOException {
        String sourcePath = "testEmptySource.txt";
        String targetPath = "testEmptyTarget.txt";
        new File(sourcePath).createNewFile();
        FileCopier.copyTextFile(sourcePath, targetPath);
        File targetFile = new File(targetPath);
        assertTrue(targetFile.exists());
        assertEquals(0, targetFile.length());
    }
    @Test
    public void testCopyTextFile_NonExistingSourceFile() {
        String sourcePath = "nonExistingSource.txt";
        String targetPath = "shouldNotExist.txt";
        assertThrows(IOException.class, () -> {
            FileCopier.copyTextFile(sourcePath, targetPath);
        });
    }
    @Test
    public void testCopyTextFile_TargetFileExists() throws IOException {
        String sourcePath = "testSourceOverwrite.txt";
        String targetPath = "testTargetOverwrite.txt";
        try (FileWriter sourceWriter = new FileWriter(sourcePath)) {
            sourceWriter.write("New Content");
        }
        try (FileWriter targetWriter = new FileWriter(targetPath)) {
            targetWriter.write("Old Content");
        }
        FileCopier.copyTextFile(sourcePath, targetPath);
        StringBuilder content = new StringBuilder();
        try (FileReader fileReader = new FileReader(targetPath)) {
            int character;
            while ((character = fileReader.read()) != -1) {
                content.append((char) character);
            }
        }
        assertEquals("New Content", content.toString());
    }
    @Test
    public void testCopyTextFile_SpecialCharacters() throws IOException {
        String sourcePath = "testSpecialCharactersSource.txt";
        String targetPath = "testSpecialCharactersTarget.txt";
        String specialContent = "Spécial Chârâctèrs! 中文字符";
        try (FileWriter fileWriter = new FileWriter(sourcePath)) {
            fileWriter.write(specialContent);
        }
        FileCopier.copyTextFile(sourcePath, targetPath);
        StringBuilder content = new StringBuilder();
        try (FileReader fileReader = new FileReader(targetPath)) {
            int character;
            while ((character = fileReader.read()) != -1) {
                content.append((char) character);
            }
        }
        assertEquals(specialContent, content.toString());
    }
}


import java.util.UUID;
import java.util.regex.Pattern;
public class UserIdentifierGenerator {
    public static String generateUserId(String email, String phone) {
        if (email != null && !email.isEmpty() && isValidEmail(email)) {
            return email;
        } else if (phone != null && !phone.isEmpty()) {
            return phone;
        } else {
            String uuid = UUID.randomUUID().toString();
            return uuid.replaceAll("-", "");
        }
    }
    private static boolean isValidEmail(String email) {
        String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$";
        Pattern pattern = Pattern.compile(emailRegex);
        return pattern.matcher(email).matches();
    }
    public static void main(String[] args) {
        System.out.println(generateUserId("example@example.com", "1234567890"));
        System.out.println(generateUserId("", "1234567890"));
        System.out.println(generateUserId("", ""));
        System.out.println(generateUserId(null, null));
        System.out.println(generateUserId("invalidEmail@", "1234567890"));
    }
}

Please write a Java function that generates a unique user identifier. If possible, first attempt to use the user's email address as the identifier. If the email address is empty or incorrectly formatted, then use the user's phone number. If the phone number is also unavailable, generate a random UUID as the user identifier. Ensure that the UUID does not contain any hyphens. Consider exception handling in the implementation, and make sure the returned identifier is a non-empty string.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.UUID;
import java.util.regex.Pattern;
public class UserIdentifierGenerator {
    public static String generateUserId(String email, String phone) {
    }
    private static boolean isValidEmail(String email) {
    }
}
```

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
public class UserIdentifierGeneratorTest {
    @Test
    public void testGenerateUserIdWithValidEmail() {
        String email = "example@example.com";
        String phone = "1234567890";
        String result = UserIdentifierGenerator.generateUserId(email, phone);
        assertEquals(email, result);
    }
    @Test
    public void testGenerateUserIdWithInvalidEmailAndValidPhone() {
        String email = "invalidEmail@";
        String phone = "1234567890";
        String result = UserIdentifierGenerator.generateUserId(email, phone);
        assertEquals(phone, result);
    }
    @Test
    public void testGenerateUserIdWithEmptyEmailAndPhone() {
        String email = "";
        String phone = "";
        String result = UserIdentifierGenerator.generateUserId(email, phone);
        assertNotNull(result);
        assertNotEquals(email, result);
        assertNotEquals(phone, result);
    }
    @Test
    public void testGenerateUserIdWithNullEmailAndPhone() {
        String email = null;
        String phone = null;
        String result = UserIdentifierGenerator.generateUserId(email, phone);
        assertNotNull(result);
    }
    @Test
    public void testGenerateUserIdWithEmptyEmailAndValidPhone() {
        String email = "";
        String phone = "1234567890";
        String result = UserIdentifierGenerator.generateUserId(email, phone);
        assertEquals(phone, result);
    }
}


import java.util.HashMap;
import java.util.Map;
public class ColumnValueConverter {
    private Map<Integer, Object> columnData;
    public ColumnValueConverter() {
        columnData = new HashMap<>();
    }
    public void setColumnValue(int col, Object value) {
        columnData.put(col, value);
    }
    public int getIntegerFromColumn(int col) {
        Object value = columnData.get(col);
        if (value == null) {
            return 0;
        }
        if (value instanceof Boolean) {
            return (Boolean) value ? 1 : 0;
        }
        try {
            return Integer.parseInt(value.toString());
        } catch (NumberFormatException e) {
            try {
                return (int) Double.parseDouble(value.toString());
            } catch (NumberFormatException ex) {
                throw new IllegalArgumentException("无法将列值转换为整数。");
            }
        }
    }
    public static void main(String[] args) {
        ColumnValueConverter converter = new ColumnValueConverter();
        converter.setColumnValue(1, null);
        converter.setColumnValue(2, true);
        converter.setColumnValue(3, false);
        converter.setColumnValue(4, "123");
        converter.setColumnValue(5, "123.456");
        converter.setColumnValue(6, "非数字");
        assert converter.getIntegerFromColumn(1) == 0 : "列值为null时应返回0";
        assert converter.getIntegerFromColumn(2) == 1 : "列值为true时应返回1";
        assert converter.getIntegerFromColumn(3) == 0 : "列值为false时应返回0";
        assert converter.getIntegerFromColumn(4) == 123 : "列值为数字字符串时应转换为整数";
        assert converter.getIntegerFromColumn(5) == 123 : "列值为浮点数字符串时应转换为整数";
        try {
            converter.getIntegerFromColumn(6);
            assert false : "列值为非数字字符串时应抛出异常";
        } catch (IllegalArgumentException e) {
            assert true : "列值为非数字字符串时应抛出异常";
        }
        System.out.println("所有测试通过！");
    }
}

Please write a Java method that accepts an integer parameter representing a column index, and returns the column value converted to an integer. If the column value is null, return 0. If the column value is of boolean type, return 1 (true) or 0 (false). If the column value is of another type, attempt to convert it to an integer. If it cannot be directly converted, try to convert it to a double, then to an integer. Ensure that the code can handle possible exceptions.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.HashMap;
import java.util.Map;
public class ColumnValueConverter {
    private Map<Integer, Object> columnData;
    public ColumnValueConverter() {
    }
    public void setColumnValue(int col, Object value) {
    }
    public int getIntegerFromColumn(int col) {
    }
}
```

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class ColumnValueConverterTest {
    private ColumnValueConverter converter;
    @BeforeEach
    public void setUp() {
        converter = new ColumnValueConverter();
    }
    @Test
    public void testColumnValueIsNull() {
        converter.setColumnValue(1, null);
        Assertions.assertEquals(0, converter.getIntegerFromColumn(1), "列值为null时应返回0");
    }
    @Test
    public void testColumnValueIsTrue() {
        converter.setColumnValue(2, true);
        Assertions.assertEquals(1, converter.getIntegerFromColumn(2), "列值为true时应返回1");
    }
    @Test
    public void testColumnValueIsFalse() {
        converter.setColumnValue(3, false);
        Assertions.assertEquals(0, converter.getIntegerFromColumn(3), "列值为false时应返回0");
    }
    @Test
    public void testColumnValueIsIntegerString() {
        converter.setColumnValue(4, "123");
        Assertions.assertEquals(123, converter.getIntegerFromColumn(4), "列值为数字字符串时应转换为整数");
    }
    @Test
    public void testColumnValueIsDoubleString() {
        converter.setColumnValue(5, "123.456");
        Assertions.assertEquals(123, converter.getIntegerFromColumn(5), "列值为浮点数字符串时应转换为整数");
    }
    @Test
    public void testColumnValueIsNonNumericString() {
        converter.setColumnValue(6, "非数字");
        Assertions.assertThrows(IllegalArgumentException.class, () -> converter.getIntegerFromColumn(6), "列值为非数字字符串时应抛出异常");
    }
}