-
public class BusinessDayService { private final BusinessDayRepository businessDayRepository; public BusinessDayService(BusinessDayRepository businessDayRepository) { this.businessDayRepository = businessDayRepository; } public BusinessDay addBusinessDay(BusinessDay businessDay) { return businessDayRepository.save(businessDay); } public BusinessDay updateBusinessDay(Long id, BusinessDay businessDay) { BusinessDay existingBusinessDay = businessDayRepository.findById(id) .orElseThrow(() -> new NotFoundException("Business day not found with ID: " + id)); existingBusinessDay.setDate(businessDay.getDate()); existingBusinessDay.setOpeningTime(businessDay.getOpeningTime()); existingBusinessDay.setClosingTime(businessDay.getClosingTime()); return businessDayRepository.save(existingBusinessDay); } public BusinessDay getBusinessDay(Long id) { return businessDayRepository.findById(id) .orElseThrow(() -> new NotFoundException("Business day not found with ID: " + id)); } public List<BusinessDay> getAllBusinessDays() { return businessDayRepository.findAll(); } }public class StoreService { public Store saveStore(Store store) { Map<DayOfWeek, BusinessHours> businessHoursByDayOfWeek = store.getBusinessHoursByDayOfWeek(); BusinessHours defaultBusinessHours = store.getDefaultBusinessHours(); for (DayOfWeek dayOfWeek : DayOfWeek.values()) { if (!businessHoursByDayOfWeek.containsKey(dayOfWeek)) { businessHoursByDayOfWeek.put(dayOfWeek, defaultBusinessHours); } } store.setBusinessHoursByDayOfWeek(businessHoursByDayOfWeek); return store; } }public class WriteReviewActivity extends AppCompatActivity { private boolean userEligibleToWriteReview; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_write_review); userEligibleToWriteReview = checkUserEligibilityForReview(); if (userEligibleToWriteReview) { } else { Toast.makeText(this, "매장을 이용한 유저만 리뷰 작성이 가능합니다.", Toast.LENGTH_LONG).show(); finish(); } } private boolean checkUserEligibilityForReview() { return true; } private void submitReview(String reviewText, int rating) { if (userEligibleToWriteReview) { Toast.makeText(this, "리뷰가 등록되었습니다", Toast.LENGTH_SHORT).show(); finish(); } else { Toast.makeText(this, "매장을 이용한 유저만 리뷰 작성이 가능합니다.", Toast.LENGTH_LONG).show(); } } }import java.util.ArrayList; import java.util.List; public class RatingCalculator { private List<Integer> ratings = new ArrayList<>(); public void addRating(int rating) { if (rating >= 1 && rating <= 5) { ratings.add(rating); } else { } } public double calculateAverageRating() { if (ratings.isEmpty()) { return 0.0; } int totalRatings = ratings.size(); int sumRatings = 0; for (int rating : ratings) { sumRatings += rating; } double averageRating = (double) sumRatings / totalRatings; averageRating = Math.round(averageRating * 10.0) / 10.0; return averageRating; } }