Skip to content
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions coding.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this unnecessary class

<module external.linked.project.id="coding" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
148 changes: 148 additions & 0 deletions src/main/java/org/fundacionjala/coding/Fernando/BankOCR/BankOCR.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package org.fundacionjala.coding.Fernando.BankOCR;

import java.util.HashMap;
import java.util.Map;

/**
* Created by PC on 24/06/2017.
*/
public final class BankOCR {

private static final int ZERO = 0;
private static final int ONE = 1;
private static final int TWO = 2;
private static final int THREE = 3;
private static final int FOUR = 4;
private static final int FIVE = 5;
private static final int SIX = 6;
private static final int SEVEN = 7;
private static final int EIGHT = 8;
private static final int NINE = 9;
private static final Map<Integer, String> MAP = new HashMap<>();
static final int VALIDATOR = 11;

static {
MAP.put(ZERO,
" _ "
+ "| |"
+ "|_|");
MAP.put(ONE,
" "
+ " |"
+ " |");
MAP.put(TWO,
" _ "
+ " _|"
+ "|_ ");
MAP.put(THREE,
"__ "
+ " _|"
+ "__|");
MAP.put(FOUR,
" "
+ "|_|"
+ " |");
MAP.put(FIVE,
" _ "
+ "|_ "
+ " _|");
MAP.put(SIX,
" _ "
+ "|_ "
+ "|_|");
MAP.put(SEVEN,
"__ "
+ " |"
+ " |");
MAP.put(EIGHT,
" _ "
+ "|_|"
+ "|_|");
MAP.put(NINE,
" _ "
+ "|_|"
+ " _|");
}

/**
* Constructor BankOCR.
*/
private BankOCR() {

}

/**
* @param value of string numbers.
* @return String of value number.
*/
private static String getMapKey(final String value) {
String res = "?";
for (Map.Entry<Integer, String> entry : MAP.entrySet()) {
if (entry.getValue().equals(value)) {
res = entry.getKey().toString();
}
}
return res;
}

/**
* @param cad value of string numbers.
* @return String to get the all numbers.
*/
public static String parseDigit(final String[] cad) {
String res = "";
StringBuilder value = new StringBuilder();
for (String data : cad) {
String key = getMapKey(data);
res = value.append(key).toString();
}

return res;
}

/**
* @param cad value of string numbers.
* @return String to get the ERR o ILL error result.
*/
public static String accountStatus(final String cad) {
String res = "";
if (!digit(cad)) {
res = "ILL";
} else if (!validAccountNumbers(cad)) {
res = "ERR";
}
return res;
}

/**
* @param data value of string numbers.
* @return boolean to get if is a valid digit.
*/
private static boolean digit(final String data) {
boolean isDigit = true;
for (int i = 0; i < data.length(); i++) {
if (!Character.isDigit(data.charAt(i))) {
isDigit = false;
break;
}
}
return isDigit;
}

/**
* @param input String value.
* @return boolean valor if is valid account number.
*/
public static boolean validAccountNumbers(final String input) {
int suma = 0;
for (int i = input.length() - 1; i >= 0; i--) {
int multiplier = 1;
int x = (int) (input.charAt(i)) * multiplier;
suma += x;
multiplier++;
}
return suma % VALIDATOR == 0;
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.fundacionjala.coding.Fernando.CadenaInv;

/**
* Write a description of class CadInv here.
*
* @author (your name)
* @version (a version number or a date)
*/
public final class CadInv {
static final int CANTMAYOR = 5;

/**
* @param text param.
* @return String param.
*/
public String cadenaInv(final String text) {
int pos = 0;
String[] parts = text.split(" ");
while (pos < parts.length) {
String palabra = parts[pos];
if (palabra.length() > CANTMAYOR) {
StringBuilder sb = new StringBuilder(parts[pos]);
parts[pos] = sb.reverse().toString();
}
pos++;
}
return String.join(" ", parts);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.fundacionjala.coding.Fernando.CheckSum;

/**
* Write a description of class CheckSum here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CheckSum {
static final int TRES = 3;
static final int UNO = 1;
static final int DIEZ = 10;
static final int DOS = 2;
static final int OCHO = 8;
static final int ZERO = 0;
static final int SIZEVALUE = 13;

/**
* @param valor data.
* @return boolean of cant values.
*/
public boolean canValores(final String valor) {
int sum = ZERO;
if (valor.length() != SIZEVALUE) {
return false;
}
for (int i = UNO; i < valor.length(); i++) {
int num = Character.getNumericValue(valor.charAt(i - 1));
sum += i % 2 == 0 ? num * TRES : num;
}
return numeroValido(sum) == Character.getNumericValue(valor.charAt(valor.length() - 1));
}
/**
* @param sum of values.
* @return int of number valid.
*/
public int numeroValido(final int sum) {
int result = sum % DIEZ;
return result != 0 ? DIEZ - result : 0;

}

}
45 changes: 45 additions & 0 deletions src/main/java/org/fundacionjala/coding/Fernando/Exam/Prom.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.fundacionjala.coding.Fernando.Exam;

/**
* Write a description of class Prom here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Prom {
/**
* Constructor.
*/
public Prom() {
}

/**
* @param num the method has a int value.
* @return double value.
*/
public double[] promedio(final int[] num) {
double[] res = {};
if (num != null && num.length != 0) {
return promedio(num, 0);
}
return res;
}

/**
* @param num the method has a int value.
* @param pos1 param.
* @return double value.
*/
private double[] promedio(final int[] num, final int pos1) {
double[] res = new double[num.length - 1];

for (int pos = 0; pos < num.length - 1; pos++) {
double primvalor = num[pos];
double secondvalor = num[pos + 1];
double prom = (primvalor + secondvalor) / 2;
res[pos] = prom;
}
return res;

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.fundacionjala.coding.Fernando.evaporator;

/**
* Created by PC on 28/06/2017.
*/
public abstract class Evaporator {


private static final double PORCENTAGE = 100;

/**
* @param content the cant of gas.
* @param evapPerDay PORCENTAGE_NUMBER of gas lost every day.
* @param limit of the gas.
* @return int report days the evaporator will be out of use.
*/
public static int evaporator(final double content, final double evapPerDay, final double limit) {
int res = 0;
double reduceConten = content;
double limitContent = content * limit / PORCENTAGE;
while (reduceConten >= limitContent) {
reduceConten = reduceConten - (reduceConten * evapPerDay / PORCENTAGE);
res++;
}
return res;

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.fundacionjala.coding.Fernando.haghestandlowest;

/**
* Created by PC on 24/06/2017.
*/
public final class HighAndLow {

/**
* Method constructor.
*/
private HighAndLow() {
}

/**
* This method get the high and low number.
*
* @param numbers to get the high and low number.
* @return String method.
*/
static String highAndLowest(final String numbers) {
String[] value = numbers.split(" ");
int majorNumber = Integer.parseInt(value[0]);
int minorNumber = majorNumber;
for (String res : value) {
int num = Integer.parseInt(res);
if (num > majorNumber) {
majorNumber = Integer.parseInt(res);
}
if (num < minorNumber) {
minorNumber = Integer.parseInt(res);
}
}

return String.format("%d %d", majorNumber, minorNumber);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.fundacionjala.coding.Fernando.movies;

/**
* Created by Administrator on 3/21/2017.
*/
public class Children extends Movie {
private static final int LIMITNEWCHILD = 3;
private static final double PRICE = 1.5;

/**
* @param title param.
*/
public Children(final String title) {
super(title);
}

/**
* @param daysRented param.
* @return double value.
*/
@Override
public double calculateAmount(final int daysRented) {
double amount = PRICE;
if (daysRented > LIMITNEWCHILD) {
amount += (daysRented - LIMITNEWCHILD) * PRICE;
}
return amount;
}

/**
* @param daysRented param.
* @return int value.
*/
@Override
public int calculateFrequentRenterPoints(final int daysRented) {
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a constant for that

}
}
Loading