id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
35b44ad6-4fb7-4d81-bd29-f9dd2a359020 | public WoodBehavior(Navigator navigator){
initial_speed=Hardware.MotorLeftSpeed;
this.nav=navigator;
} |
51867881-13f2-45bb-8b16-f7ae58b5cfee | @Override
public boolean takeControl() {
return Hardware.RangeWood.contains(Hardware.SensorLight.readValue())
&& (Hardware.getCurrentMode()!= Hardware.REMOTE_SIMPLE)
&& (Hardware.getCurrentMode()!= Hardware.REMOTE_MODE);
} |
2da9e9ba-52a9-45ca-80af-851278879b91 | @Override
public void action() {
this.nav.stop();
int angle = 10;
for (
int i = 1;
!this.suppressed && Hardware.RangeWood.contains(Hardware.SensorLight.readValue());
i++){
LCD.clear(0);
LCD.drawString("CONTROL "+Hardware.SensorLight.readValue(), 0, 0);
((DifferentialPilot)this.n... |
c02090ff-cb57-4380-9dbb-f6b8b2708815 | @Override
public void suppress() {
this.suppressed = true;
} |
899abe8d-fd32-45dd-bf7b-3bfe9c855e76 | public static void main(String[] args) {
for (int i = 1; i < 1000000; i++) {
if (sameDigits(i, i * 2)) {
if (sameDigits(i, i * 3)) {
if (sameDigits(i, i * 4)) {
if (sameDigits(i, i * 5)) {
if (sameDigits(i, i*6))... |
5e1461da-7fda-4a64-8f29-b0a79934f242 | public static boolean sameDigits(int n, int j) {
boolean[] num1 = new boolean[10];
boolean[] num2 = new boolean[10];
String numN = Integer.toString(n);
String numJ = Integer.toString(j);
if (numN.length() != numJ.length()) {
return false;
}
... |
ca42f115-df4a-4feb-b772-2f214de2be8b | public static void main(String[] args) {
for (int i = 20; i < 1000000000; i = i + 20) {
if (i % 19 == 0 && i % 18 == 0 && i % 17 == 0 && i % 16 == 0 && i % 15 == 0 && i % 14 == 0 &&
i % 13 == 0 && i % 12 == 0 && i % 11 == 0 && i % 7 == 0) {
System.out.println(i);
break;
}
}
} |
0161852e-b537-4c34-93e2-b29542096ea9 | public static void main(String[] args) {
System.out.println(singleDigit() + tens() + (doubleDigit() * 9) + (singleDigit() * 9 * 9)
+ (singleDigit() * 100) + (7*900) + (3*891)
+ ((singleDigit() + tens() + (doubleDigit() * 9) + (singleDigit() * 9 * 9)) * 9)
... |
a25e4773-266a-4fa9-8127-cb4fecd7d62d | public static int singleDigit() {
String s = "one" + "two" + "three" + "four" + "five" + "six" + "seven" + "eight" + "nine";
return s.length();
} |
35d05fd0-1961-4d03-8364-2ff30286b26d | public static int doubleDigit() {
String s = "twenty" + "thirty" + "fourty" + "fifty" + "sixty" + "seventy" + "eighty" + "ninety";
return s.length();
} |
179b29fb-fd5f-45ef-83fc-752afbeb52a8 | public static int tens() {
String s = "ten" + "eleven" + "twelve" + "thirteen" + "fourteen" + "fifteen" + "sixteen" + "seventeen"
+ "eighteen" + "nineteen";
return s.length();
} |
ea9b239d-ec29-4224-b1e9-7f2cf6d980ba | public static void main(String[] args) {
ArrayList<Integer> primes = getFourDigitPrimes();
int[] ret = new int[3];
for (int j = 0 ; j < primes.size(); j++) {
int num = primes.get(j);
ret[0] = num;
for (int i = j+1; i < primes.size(); i++) {
if (isPermutat... |
4cbb39d1-3479-42cf-90e1-61fcc584eb41 | public static boolean isPermutation(int n, int j) {
boolean[] num1 = new boolean[10];
boolean[] num2 = new boolean[10];
String numN = Integer.toString(n);
String numJ = Integer.toString(j);
for (int i = 0; i < 4; i++) {
num1[Integer.parseInt(Character.toString(numN.charAt(i)))] = tr... |
266ab32c-55b3-461c-9220-9df42ae1ed92 | public static ArrayList<Integer> getFourDigitPrimes() {
ArrayList<Integer> primes = new ArrayList<Integer>();
for (int i = 1000; i < 10000; i++) {
if (isPrime(i)) {
primes.add(i);
}
}
return primes;
} |
3a57caba-cc64-45aa-9e31-b16c6b3ad73e | public static boolean isPrime(int n) {
for (int i = 2; i < n/2 - 1; i++) {
if (n % i == 0) {
return false;
}
}
return true;
} |
2754f77e-4df0-4348-8570-42fe654105fd | public static void main(String[] args) {
int numOfWords = 0;
} |
2e6a9fb0-b625-4908-b2d1-45591a10fafc | public static int getValue(String n) {
int value = 0;
for (int i = 0; i < n.length()-1; i++) {
char currentLetter = n.charAt(i);
value = value + (Character.getNumericValue(currentLetter) - 9);
}
return value;
} |
fb148999-fa1d-4441-9f40-be3f014fdfcd | public boolean isTriangleNumber(int n) {
return Arrays.asList(getFirst30TriangleNumbers()).contains(n);
} |
0ee4de69-e84d-47dd-a0c9-1c418d8c5e1c | public static int[] getFirst30TriangleNumbers() {
int[] results = new int[30];
for (int i = 0; i < 30; i++) {
results[i] = ((i+1)/2) * (i+2);
}
return results;
} |
7f57540d-22a6-4437-9eee-ab0db0313714 | public static void main(String[] args) {
Hashtable<Integer, Integer> h = getAllAbundants();
ArrayList<Integer> a = getAllAbundantsArray();
int totalSum = 0;
for (int i = 24; i <= 28123; i++) {
outerloop:
for (int j : a) {
if (h.get(i-j) != null &... |
23f9ccc0-2e9a-4166-aaf8-2d93eed47125 | public static Hashtable<Integer, Integer> getAllAbundants() {
Hashtable<Integer, Integer> h = new Hashtable<Integer, Integer>();
for (int i = 12; i < 28123; i++) {
if (isAbundant(i)) {
h.put(i, i);
}
}
return h;
} |
4c7885e9-755a-4663-8aa9-2a5a54d6cf43 | public static ArrayList<Integer> getAllAbundantsArray() {
ArrayList<Integer> abundants = new ArrayList<Integer>();
for (int i = 12; i < 28123; i++) {
if (isAbundant(i)) {
abundants.add(i);
}
}
return abundants;
} |
e3ebcc0a-027e-4f8a-b2e2-f29e98156de2 | public static boolean isAbundant(int i) {
ArrayList<Integer> factors = getFactors(i);
int sumOfFactors = 0;
for (int num : factors) {
sumOfFactors = sumOfFactors + num;
}
return sumOfFactors > i;
} |
967b763a-71df-41b5-822c-c2ed5ce1455c | public static ArrayList<Integer> getFactors(int num) {
ArrayList<Integer> factors = new ArrayList<Integer>();
for (int i = 1; i < num/2 + 1 ; i++) {
if (num % i == 0) {
factors.add(i);
}
}
return factors;
} |
7a36fede-7ca2-47c7-8f4a-fe16c5e3c8f9 | public static void main(String[] args) {
int num = 1000;
for (int i = 1; i < 10; i++) {
num = num * num;
}
System.out.println(num);
} |
dd5c2300-aeb8-401a-bf6c-8098ee19c1b3 | public static void main(String[] args) {
System.out.println(getBigNumber(1));
System.out.println(getBigNumber(10));
System.out.println(getBigNumber(100));
System.out.println(getBigNumber(1000));
System.out.println(getBigNumber(10000));
System.out.println(getBigNumber(100000));
} |
fa0c8dc7-9c9d-4ddc-b99c-525f6e7799c9 | public static char getBigNumber(int digits) {
String s = "";
int startNumber = 0;
while (s.length() <= digits) {
s = s + (startNumber + 1);
startNumber++;
}
return s.charAt(digits-1);
} |
94ed69fe-aebb-4650-9210-3ec505132453 | public static void main(String[] args) {
int firstNum = 1;
int secondNum = 2;
int oldFirstNum = 0;
int sumOfFibs = 0;
while (secondNum < 4000000) {
if (secondNum % 2 == 0) {
sumOfFibs = sumOfFibs + secondNum;
}
oldFirstNum = firstNum;
firstNum = secondNum;
secondNum = oldFirstNum ... |
e2950a6f-8eac-49bb-9499-b491ac7dac0a | public static void main(String[] args) {
for (int i = 2142; i < 999999999; i++) {
if (isPandigital(i)) {
if (isPrime(i)) {
System.out.println(i);
}
}
}
} |
fa24d7c7-5379-426e-86eb-dee5e743004c | public static boolean isPandigital(int n) {
String num = Integer.toString(n);
for (int i = 1; i <= num.length(); i++) {
if (!num.contains(Integer.toString(i))) {
return false;
}
}
return true;
} |
f070a5b0-ba3c-40ae-a988-874abf9a08e3 | public static boolean isPrime(int n) {
for (int i = 2; i < n/2 - 1; i++) {
if (n % i == 0) {
return false;
}
}
return true;
} |
db17b10c-507c-430f-b7e0-d714d733808c | public static void main(String[] args) {
int result = 0;
for (int i = 0; i < 1000; i++) {
if (i % 3 == 0 || i % 5 == 0) {
result = result + i;
}
}
System.out.println(result);
} |
44f683aa-a576-4d74-90d1-e27a04a6765b | public static void main(String[] args) {
int currentPrimeCount = 0;
int firstPrime = 2;
for (firstPrime = 2; currentPrimeCount < 10001; firstPrime++) {
if (isPrime(firstPrime)) {
currentPrimeCount++;
System.out.println(firstPrime);
... |
fcb2629c-8ae2-4c41-8397-158d365d2add | public static boolean isPrime(int n) {
for (int i = 2; i < n/2 + 1; i++) {
if (n % i == 0) {
return false;
}
}
return true;
} |
db358cbe-5b6e-401a-92dd-2c7ea131fc71 | public Usuario buscaUsuarioPorId(Integer usuarioId) {
Session sesion = sessionFactory.openSession();
sesion.beginTransaction();
// INICIA TRANSACCION
Usuario usuario = (Usuario) sesion.get(Usuario.class, usuarioId);
// obteniendo la transaccion actual y guardando todos los
// cambios en la base
sesion.g... |
962de3c6-d76c-493f-8d0d-7fc65d59c091 | public void creaUsuario(Usuario usuario) {
Session sesion = sessionFactory.openSession();
sesion.beginTransaction();
// INICIA TRANSACCION
sesion.saveOrUpdate(usuario);
// obteniendo la transaccion actual y guardando todos los
// cambios en la base
sesion.getTransaction().commit();
sesion.close();
} |
4c926d39-685f-4387-b7ac-0d826b9bc9b8 | public Usuario buscaPorEmailYPassword(String email, String password) {
Session sesion = sessionFactory.openSession();
sesion.beginTransaction();
// FORMAMOS EL CRITERIO DE HIBERNATE
Criteria criterio = sesion.createCriteria(Usuario.class);
//EJEMPLO DE CRITERIO USANDO OR
/*
criterio.add(Restrictions.or... |
c02f827a-8bd3-4884-b051-4ee2d89a6ada | public List<Usuario> buscaPorNombre(String nombre) {
Session sesion = sessionFactory.openSession();
sesion.beginTransaction();
// FORMAMOS EL CRITERIO DE HIBERNATE
Criteria criterio = sesion.createCriteria(Usuario.class);
criterio.add(Restrictions.like("nombre","%" + nombre + "%"));
List<Usuario> usuari... |
df731dc9-c54c-4fc8-ad5c-e8d682bf3085 | public Usuario buscaUsuarioPorId(Integer usuarioId); |
465ba1e2-34e7-4976-8fd0-6761a4fd1789 | public void creaUsuario(Usuario usuario); |
a929f842-b4ed-4f7d-8c9a-4f4e69b3f057 | public Usuario buscaPorEmailYPassword(String email, String password); |
2d1a8c03-3bca-4321-b7e8-455404001451 | List<Usuario> buscaPorNombre(String nombre); |
875edda1-7ebf-4ee0-b62e-3315242979e2 | public String getEmail() {
return email;
} |
ce84cdf8-cb94-4c45-87e7-3415dd7820d9 | public void setEmail(String email) {
this.email = email;
} |
e3fd3c75-da19-407e-a6f5-872e029e0937 | public Integer getUsuarioId() {
return usuarioId;
} |
7c6b197d-30cb-4a8f-bc53-6584c3f347b4 | public void setUsuarioId(Integer usuarioId) {
this.usuarioId = usuarioId;
} |
94246161-9963-4bc8-9bd3-f8c860a5d73d | public String getPassword() {
return password;
} |
06220a90-78a4-4044-b053-4085ed874f03 | public void setPassword(String password) {
this.password = password;
} |
c8ac9d1c-0beb-4595-866e-1f21edeb9798 | public String getNombre() {
return nombre;
} |
e618851f-6d12-4dc7-b2db-12de7433a174 | public void setNombre(String nombre) {
this.nombre = nombre;
} |
51e62335-e6d5-4eb4-8456-18b8a0ff3267 | @Override
public String toString() {
StringBuilder builder;
builder = new StringBuilder();
builder.append("[");
builder.append("usuarioId:").append(this.usuarioId).append(", ");
builder.append("email:").append(this.email).append(", ");
builder.append("password:").append(this.password).append(", ");
buil... |
e6927bb2-b19a-4870-899a-b3de57442331 | public static void main(String[] args) {
//creamos el contexto de Spring
ApplicationContext contexto = new ClassPathXmlApplicationContext("/contexto.xml");
//nos traemos el bean HibernateUsuarioDAO
UsuarioDAO usuarioDAO = (UsuarioDAO) contexto.getBean("usuarioDAO");
Usuario usuario = new Usuario();
us... |
ea894b3f-6666-4f77-ba4e-4e0734d0de2a | @Query("select e from Employee e where e.email=:email")
public Employee findOneByEmail(@Param("email") String email); |
3a5a078c-14be-4bfb-8fbd-2c4522bf6b1f | @Query("select e from Employee e where e.lastname=:lastname")
public List<Employee> findAllByLastname(@Param("lastname") String lastname); |
cbce0925-febf-4f22-8a52-4290a693d28b | public void add(Employee employee); |
dbae8a11-b40c-4d9c-a52b-48550f30df3d | public List<Employee> getAll(); |
b96e1223-13c3-4848-a664-14768d799101 | public Employee get(Integer id); |
4e3369ad-601e-4f67-b3b0-35517827edeb | public void delete(Integer employeeId); |
e336eb72-fec1-4317-b0a9-29e7adca2588 | @Override
@Transactional
public void add(Employee employee) {
employeeDao.save(employee);
} |
e07a029e-a9ea-4751-b4b3-a33e6c6b7688 | @Override
@Transactional
public List<Employee> getAll() {
return employeeDao.findAll();
} |
3f8489be-2dbc-434c-bcd3-f93939efe123 | @Override
@Transactional
public Employee get(Integer id) {
return employeeDao.findOne(id);
} |
4d4fa70b-1176-411e-8b87-8de797426055 | @Override
@Transactional
public void delete(Integer employeeId) {
employeeDao.delete(employeeId);
} |
057de162-cacd-41fe-83f8-66e5d6ebd37c | @Override
public String intercept(ActionInvocation invocation) throws Exception {
Map<String, Object> session = invocation.getInvocationContext()
.getSession();
User user = (User) session.get("user");
if (user == null) {
return "login";
}
System.out.println("invoke interceptor : " + user);
return... |
0c050ede-1ff4-4872-85c0-9014c68ccde9 | public Employee() {
} |
f1626e4a-d67a-4228-af5a-498a0248df11 | public Employee(Integer id, String firstname, String lastname,
String email, String telephone) {
super();
this.id = id;
this.firstname = firstname;
this.lastname = lastname;
this.email = email;
this.telephone = telephone;
} |
5c9db345-dc3b-4bdd-a2fb-5beb30e56fd7 | public Integer getId() {
return id;
} |
ecd3c00b-50a9-4d7f-8af7-12e063d81a90 | public void setId(Integer id) {
this.id = id;
} |
f2e0378b-7667-4372-ad5f-8889fccc8165 | public String getFirstname() {
return firstname;
} |
476109ee-a92a-4c96-a989-34e7d77e4dbe | public void setFirstname(String firstname) {
this.firstname = firstname;
} |
2e569d90-aaf0-4d3b-a5bf-443700957260 | public String getLastname() {
return lastname;
} |
9b44871f-f0eb-4e8b-9406-752c8a146b84 | public void setLastname(String lastname) {
this.lastname = lastname;
} |
48b86b38-c282-48db-b536-77acd899ee70 | public String getEmail() {
return email;
} |
a4b3946e-3de3-4cd4-9f01-91fdcc669847 | public void setEmail(String email) {
this.email = email;
} |
f1e06fac-c455-49f1-90aa-7ecb03bb9966 | public String getTelephone() {
return telephone;
} |
cae415d9-f1cc-4e0e-afc3-c7282e5f8514 | public void setTelephone(String telephone) {
this.telephone = telephone;
} |
ee068e5d-399e-4387-8017-5c396dda0f59 | @Override
public String toString() {
return "EmployeeEntity [id=" + id + ", firstname=" + firstname
+ ", lastname=" + lastname + ", email=" + email
+ ", telephone=" + telephone + "]";
} |
920fb1b2-6d1e-436c-9553-c3d38b604e72 | public User() {
} |
48b444a4-831c-4898-867a-e2e0ee260ff0 | public String getName() {
return name;
} |
4d8c0845-a145-4403-9658-59b1566d78ad | public void setName(String name) {
this.name = name;
} |
b8274cb2-e0da-4f53-b5fc-4010e6430c4f | public String getPassword() {
return password;
} |
4874efa6-fa36-4083-b2ea-cdf6a41e960f | public void setPassword(String password) {
this.password = password;
} |
2703767e-4e23-4a66-bd81-3e72b55863ed | @Override
public String toString() {
return "User [name=" + name + ", password=" + password + "]";
} |
009446f3-9381-46a2-b824-69d0e3bdd01b | public Product() {
} |
5e2499e2-1129-49fd-8084-ef1c9bf81d91 | public Product(Integer id, String ref, String description) {
super();
this.id = id;
this.ref = ref;
this.description = description;
} |
79ac2f2c-a899-4784-8efe-efc9ee20f55a | public Integer getId() {
return id;
} |
6aa6f6d8-6573-4cb3-9654-77021c5414cc | public void setId(Integer id) {
this.id = id;
} |
da17e5e5-b6c1-43dd-b62d-3f9ad722c999 | public String getRef() {
return ref;
} |
d962893b-5e7c-45c5-b75e-115e691c90c2 | public void setRef(String ref) {
this.ref = ref;
} |
48169403-41d2-4c82-8677-2259b30b215f | public String getDescription() {
return description;
} |
17eebbcc-deac-487b-9ca0-b0fd71e56987 | public void setDescription(String description) {
this.description = description;
} |
770a1ec4-22a1-4838-8f0c-e4e818715bb6 | @Override
public String toString() {
return "Product [id=" + id + ", ref=" + ref + ", description="
+ description + "]";
} |
bb8b30e9-d779-4140-b554-e7f9eceaae3c | @Override
public Product getModel() {
return product;
} |
5b9d5700-ef7c-40ec-a3cc-9c8341df1b1b | @Action(value = "addAction", results = {
@Result(name = SUCCESS, type = "redirectAction", location = "listAction.action"),
@Result(name = "input", location = "/product/add.jsp") })
public String addProduct() throws Exception {
System.out.println("ADD PRODUCT");
System.out.println(product);
return SUCCESS... |
8205b831-9ede-40d6-b371-30048c20c45f | @Action(value = "listAction", results = {
@Result(name = "success", location = "/product/list.jsp")})
@SkipValidation
public String listProducts() throws Exception {
products = Arrays.asList(new Product(1, "REF1", "DESC1"), new Product(2, "REF2", "DESC2"));
return "success";
} |
cb24ab45-e398-4679-b66d-9ad89985869d | public Product getProduct() {
return product;
} |
3f86341b-7329-4a41-b10a-6fe4f90589d0 | public void setProduct(Product product) {
this.product = product;
} |
21137bd7-c625-4f57-8104-cfdf9aa0d980 | public List<Product> getProducts() {
return products;
} |
c9524451-455a-4041-9090-bd6a2dec130e | public void setProducts(List<Product> products) {
this.products = products;
} |
b89f1a03-701b-4569-9a83-17151aaa307f | @Override
public String execute() throws Exception {
System.out.println(user);
session.put("user", user);
return SUCCESS;
} |
907bb607-16fb-4af8-bf3b-7841f6ffc35c | public User getUser() {
return user;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.