-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarServiceBasic.java
More file actions
45 lines (33 loc) · 1.06 KB
/
CarServiceBasic.java
File metadata and controls
45 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package ro.cristi.curs.service;
import java.math.BigDecimal;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ro.cristi.curs.model.Car;
import ro.cristi.curs.repository.CarRepository;
@Service
public class CarServiceBasic {
@Autowired
CarRepository carRepository;
public List<Car> getExpensiveCars(Integer percent){
List<Car> cars = carRepository.getAllCars();
for(Car car : cars){
car.setPrice(car.getPrice().multiply(BigDecimal.valueOf(percent)));
}
return cars;
}
public List<Car> getOlderCars(Integer years){
List<Car> cars = carRepository.getAllCars();
for(Car car : cars){
car.setYear(car.getYear() - years);
}
return cars;
}
public List<Car> getEfficientCars(Integer units){
List<Car> cars = carRepository.getAllCars();
for(Car car : cars){
car.setConsumption(car.getConsumption() - units);
}
return cars;
}
}