-
Notifications
You must be signed in to change notification settings - Fork 10
Exercises completed #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NandoOU
wants to merge
28
commits into
AT-03:develop
Choose a base branch
from
NandoOU:ExercisesCompleted
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
ef5110c
prueba
NandoOU 0698ce8
prueba2
NandoOU e37da55
Merge remote-tracking branch 'origin/develop' into develop
NandoOU d4e4a06
BankOCR
NandoOU 5cb04dd
BankOCRTest
NandoOU 7709f6d
CadenaInvertida
NandoOU f5037a4
CheckSum
NandoOU 8f1c8c6
CadInvTest
NandoOU aafc87c
CheckSumTest
NandoOU 6968c4c
Exam
NandoOU bd6795e
ExamTest
NandoOU d5fb9ff
NuevoCheckSum
NandoOU afb9a0e
Movies
NandoOU 23ffe78
MoviesTest
NandoOU 0ea81f7
Exercises Completed
c43dfe6
Evaporator kata
d00854b
Exercises Completed
caf5b8c
Exercises Completed
7caa361
Exercises Completed
2cf89a4
Exercises Completed
514ded9
Coding Exercises Refactored
NandoOU fc07e38
Coding Exercises Refactored
NandoOU 5686de4
Coding Refactored
afcf1ce
Merge branch 'develop' into ExercisesCompleted
NandoOU 5675732
Coding Exercises Completed
4fd56f0
Coding Exercises Completed
8373efc
Coding Exercises Completed
8461702
Coding Exercises Completed
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/org/fundacionjala/coding/Fernando/StringInv/StringInv.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.fundacionjala.coding.Fernando.StringInv; | ||
|
||
/** | ||
* Write a description of class StringInv here. | ||
* | ||
* @author (your name) | ||
* @version (a version number or a date) | ||
*/ | ||
public final class StringInv { | ||
|
||
static final int MAJOR_FIVE_LETTERS = 5; | ||
|
||
/** | ||
* Constructor StringInv. | ||
*/ | ||
private StringInv() { | ||
} | ||
|
||
/** | ||
* @param text param. | ||
* @return String param. | ||
*/ | ||
public static String stringInv(final String text) { | ||
int pos = 0; | ||
String[] parts = text.split(" "); | ||
while (pos < parts.length) { | ||
if (parts[pos].length() > MAJOR_FIVE_LETTERS) { | ||
parts[pos] = new StringBuilder(parts[pos]).reverse().toString(); | ||
} | ||
pos++; | ||
} | ||
return String.join(" ", parts); | ||
|
||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/org/fundacionjala/coding/Fernando/average/Average.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.fundacionjala.coding.Fernando.average; | ||
|
||
/** | ||
* Write a description of class Average here. | ||
* | ||
* @author (your name) | ||
* @version (a version number or a date) | ||
*/ | ||
public final class Average { | ||
|
||
/** | ||
* Constructor Average. | ||
*/ | ||
private Average() { | ||
} | ||
|
||
/** | ||
* @param num the method has a int value. | ||
* @return double value. | ||
*/ | ||
public static double[] average(final int[] num) { | ||
double[] res = {}; | ||
if (num != null && num.length != 0) { | ||
return average(num, 0); | ||
} | ||
return res; | ||
} | ||
|
||
/** | ||
* @param num the method has a int value. | ||
* @param pos1 param. | ||
* @return double value. | ||
*/ | ||
private static double[] average(final int[] num, final int pos1) { | ||
double[] res = new double[num.length - 1]; | ||
for (int pos = 0; pos < num.length - 1; pos++) { | ||
double prom = (double) (num[pos] + num[pos + 1]) / 2; | ||
res[pos] = prom; | ||
} | ||
return res; | ||
|
||
} | ||
} |
142 changes: 142 additions & 0 deletions
142
src/main/java/org/fundacionjala/coding/Fernando/bankOCR/BankOCR.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
package org.fundacionjala.coding.Fernando.bankOCR; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* 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) { | ||
res = value.append(getMapKey(data)).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) { | ||
return Stream.of(data.split("")). | ||
filter(a -> Character.isDigit(a.charAt(0))).count() > 0; | ||
} | ||
|
||
/** | ||
* @param input String value. | ||
* @return boolean valor if is valid account number. | ||
*/ | ||
public static boolean validAccountNumbers(final String input) { | ||
int suma = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo |
||
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; | ||
} | ||
|
||
} | ||
|
51 changes: 51 additions & 0 deletions
51
src/main/java/org/fundacionjala/coding/Fernando/checkSum/CheckSum.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.fundacionjala.coding.Fernando.checkSum; | ||
|
||
/** | ||
* Write a description of class checkSum here. | ||
* | ||
* @author (your name) | ||
* @version (a version number or a date) | ||
*/ | ||
public final class CheckSum { | ||
static final int THREE = 3; | ||
static final int ONE = 1; | ||
static final int TEN = 10; | ||
static final int TWO = 2; | ||
static final int EIGHT = 8; | ||
static final int ZERO = 0; | ||
static final int SIZEVALUE = 13; | ||
|
||
/** | ||
* Constructor checksum. | ||
*/ | ||
private CheckSum() { | ||
|
||
} | ||
|
||
/** | ||
* @param value data. | ||
* @return boolean of cant values. | ||
*/ | ||
public static boolean canValues(final String value) { | ||
int sum = ZERO; | ||
if (value.length() != SIZEVALUE) { | ||
return false; | ||
} | ||
for (int i = ONE; i < value.length(); i++) { | ||
int num = Character.getNumericValue(value.charAt(i - 1)); | ||
sum += i % 2 == 0 ? num * THREE : num; | ||
} | ||
return validNum(sum) == Character.getNumericValue(value.charAt(value.length() - 1)); | ||
} | ||
|
||
/** | ||
* @param sum of values. | ||
* @return int of number valid. | ||
*/ | ||
public static int validNum(final int sum) { | ||
int result = sum % TEN; | ||
return result != 0 ? TEN - result : 0; | ||
|
||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/org/fundacionjala/coding/Fernando/evaporator/Evaporator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.fundacionjala.coding.Fernando.evaporator; | ||
|
||
/** | ||
* Created by Administrator on 6/28/2017. | ||
*/ | ||
public final class Evaporator { | ||
|
||
private static final int PERCENTAGE_TOTAL = 100; | ||
|
||
/** | ||
* Constructor evaporator kata. | ||
*/ | ||
private Evaporator() { | ||
} | ||
|
||
/** | ||
* @param content content containing. | ||
* @param evapPerDay evaporation day. | ||
* @param limit limit. | ||
* @return life of an evaporator containing gas. | ||
*/ | ||
|
||
public static int evaporator(final double content, final double evapPerDay, final double limit) { | ||
int res = 0; | ||
double reduceConten = content; | ||
double limitContent = content * limit / PERCENTAGE_TOTAL; | ||
while (reduceConten >= limitContent) { | ||
reduceConten = reduceConten - (reduceConten * evapPerDay / PERCENTAGE_TOTAL); | ||
res++; | ||
} | ||
return res; | ||
} | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
src/main/java/org/fundacionjala/coding/Fernando/haghestandlowest/HighAndLow.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/fundacionjala/coding/Fernando/movies/Children.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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; | ||
private static final int RENT_ONE_DAY = 1; | ||
|
||
/** | ||
* @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 RENT_ONE_DAY; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this variable?