Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b8d782

Browse files
committed
Prepare_tu_HW0.patch
1 parent f11517f commit 0b8d782

File tree

5 files changed

+108
-0
lines changed

5 files changed

+108
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ log
66

77

88

9+
10+
patches
11+
.patch
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package ru.javawebinar.topjava.model;
2+
3+
import java.time.LocalDateTime;
4+
5+
/**
6+
* GKislin
7+
* 11.01.2015.
8+
*/
9+
public class UserMeal {
10+
protected final LocalDateTime dateTime;
11+
12+
protected final String description;
13+
14+
protected final int calories;
15+
16+
public UserMeal(LocalDateTime dateTime, String description, int calories) {
17+
this.dateTime = dateTime;
18+
this.description = description;
19+
this.calories = calories;
20+
}
21+
22+
public LocalDateTime getDateTime() {
23+
return dateTime;
24+
}
25+
26+
public String getDescription() {
27+
return description;
28+
}
29+
30+
public int getCalories() {
31+
return calories;
32+
}
33+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package ru.javawebinar.topjava.model;
2+
3+
import java.time.LocalDateTime;
4+
5+
/**
6+
* GKislin
7+
* 11.01.2015.
8+
*/
9+
public class UserMealWithExceed {
10+
protected final LocalDateTime dateTime;
11+
12+
protected final String description;
13+
14+
protected final int calories;
15+
16+
protected final boolean exceed;
17+
18+
public UserMealWithExceed(LocalDateTime dateTime, String description, int calories, boolean exceed) {
19+
this.dateTime = dateTime;
20+
this.description = description;
21+
this.calories = calories;
22+
this.exceed = exceed;
23+
}
24+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ru.javawebinar.topjava.util;
2+
3+
import java.time.LocalTime;
4+
5+
/**
6+
* GKislin
7+
* 07.01.2015.
8+
*/
9+
public class TimeUtil {
10+
public static boolean isBetween(LocalTime lt, LocalTime startTime, LocalTime endTime) {
11+
return lt.compareTo(startTime) >= 0 && lt.compareTo(endTime) <= 0;
12+
}
13+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package ru.javawebinar.topjava.util;
2+
3+
import ru.javawebinar.topjava.model.UserMeal;
4+
import ru.javawebinar.topjava.model.UserMealWithExceed;
5+
6+
import java.time.LocalDateTime;
7+
import java.time.LocalTime;
8+
import java.time.Month;
9+
import java.util.Arrays;
10+
import java.util.List;
11+
12+
/**
13+
* GKislin
14+
* 31.05.2015.
15+
*/
16+
public class UserMealsUtil {
17+
public static void main(String[] args) {
18+
List<UserMeal> mealList = Arrays.asList(
19+
new UserMeal(LocalDateTime.of(2015, Month.MAY, 30,10,0), "Завтрак", 500),
20+
new UserMeal(LocalDateTime.of(2015, Month.MAY, 30,13,0), "Обед", 1000),
21+
new UserMeal(LocalDateTime.of(2015, Month.MAY, 30,20,0), "Ужин", 500),
22+
new UserMeal(LocalDateTime.of(2015, Month.MAY, 31,10,0), "Завтрак", 1000),
23+
new UserMeal(LocalDateTime.of(2015, Month.MAY, 31,13,0), "Обед", 500),
24+
new UserMeal(LocalDateTime.of(2015, Month.MAY, 31,20,0), "Ужин", 510)
25+
);
26+
getFilteredMealsWithExceeded(mealList, LocalTime.of(7, 0), LocalTime.of(12,0), 2000);
27+
// .toLocalDate();
28+
// .toLocalTime();
29+
}
30+
31+
public static List<UserMealWithExceed> getFilteredMealsWithExceeded(List<UserMeal> mealList, LocalTime startTime, LocalTime endTime, int caloriesPerDay) {
32+
// TODO return filtered list with correctly exceeded field
33+
return null;
34+
}
35+
}

0 commit comments

Comments
 (0)