package service;
/**
* @author Julija
*/
import model.Alarm;
import model.Location;
import model.Product;
import model.Stack;
import model.Stack.DryState;
import dao.AlarmDao;
import dao.LocationDao;
import dao.ProductDao;
public class Service {
private static final Service INSTANCE = new Service();
private Service() {
}
public static Service getInstance() {
return INSTANCE;
}
public boolean isNumber
(String input
) { boolean isNumber = false;
for (int i = 0; i < input.length(); i++) { // Goes through the string char by char
if(isCharNumber(input.charAt(i))){
isNumber = true;
} else {
return false;
}
}
return isNumber;
}
boolean isCharNumber(char cha){
char[] number = {'0','1','2','3','4','5','6','7','8','9'};
for (int i = 0; i < 10; i++){ // Compares specific char in the string with every number as a char to test wether it is a number
if (cha == number[i]){
return true;
}
}
return false;
}
public void createObjects() {
Location area1 = new Location("Area1", "AR1");
LocationDao.storeLocation(area1);
Location area2 = new Location("Area2", "AR2");
LocationDao.storeLocation(area2);
Location area3 = new Location("Area3", "AR3");
LocationDao.storeLocation(area3);
Alarm alarm1 = new Alarm(5, 5);
AlarmDao.storeAlarm(alarm1);
Alarm alarm2 = new Alarm(5, 5);
AlarmDao.storeAlarm(alarm2);
Alarm alarm3 = new Alarm(0, 0);
AlarmDao.storeAlarm(alarm3);
for (int i=0;i<=20;i++)
{
ProductDao.storeProduct(new Product("SK"+i, "Candy made of liqorice in the middle with "+i+" coatings of colored sugar.", null));
ProductDao.storeProduct(new Product("AB"+i, "Candy made of liqorice in the middle with "+i+" coatings of colored sugar.", null));
ProductDao.storeProduct(new Product("ZF"+i, "Candy made of liqorice in the middle with "+i+" coatings of colored sugar.", null));
}
System.
out.
println(ProductDao.
getAllProducts());
}
}