-
Notifications
You must be signed in to change notification settings - Fork 10
pablo and ruber package #29
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
ReinaldoAguilar
wants to merge
3
commits into
AT-03:develop
Choose a base branch
from
CoudinReinaldo:ReinaldoKatas
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 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
32 changes: 32 additions & 0 deletions
32
src/main/java/org/fundacionjala/coding/reinaldo/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,32 @@ | ||
| package org.fundacionjala.coding.reinaldo.average; | ||
|
|
||
| import java.util.stream.IntStream; | ||
|
|
||
| /** | ||
| * Created by Administrator on 6/30/2017. | ||
| * | ||
| */ | ||
| public final class Average { | ||
| /** | ||
| * Constructor private. | ||
| */ | ||
| private Average() { | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * This method averagesCalculate verify is empty, null or only has | ||
| * one element or averges. | ||
| * | ||
| * @param sentence array. | ||
| * @return true if the array is not empty, null or has only one element. | ||
| */ | ||
| public static double[] averagesCalculate(final int[] sentence) { | ||
|
|
||
| return sentence == null || sentence.length < 2 | ||
| ? new double[0] | ||
| : IntStream.range(0, sentence.length - 1) | ||
| .mapToDouble(i -> (sentence[i] + sentence[i + 1]) / 2d).toArray(); | ||
| } | ||
| } | ||
|
|
43 changes: 43 additions & 0 deletions
43
src/main/java/org/fundacionjala/coding/reinaldo/ean/Ean.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.reinaldo.ean; | ||
|
|
||
| import java.util.stream.IntStream; | ||
|
|
||
|
|
||
| /** | ||
| * Created by Administrator on 6/30/2017. | ||
| */ | ||
| public final class Ean { | ||
|
|
||
| private static final int DIVISOR = 10; | ||
|
|
||
| /** | ||
| * This is the constructor of Ean. | ||
| */ | ||
| private Ean() { | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * @param eanCode validate checksum. | ||
| * @return boolean is checksum. | ||
| */ | ||
| static boolean validate(final String eanCode) { | ||
| final int sumToCheck = IntStream | ||
| .range(0, eanCode.length() - 1) | ||
| .reduce(0, (acc, index) | ||
| -> acc + Character.getNumericValue(eanCode.charAt(index)) * (1 + 2 * (index % 2))); | ||
|
|
||
| return Character.getNumericValue(eanCode.charAt(eanCode.length() - 1)) == getAnInt(sumToCheck); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * This method return getAnInt. | ||
| * | ||
| * @param sumToCheck sumtocheck. | ||
| * @return int getSum | ||
| */ | ||
| private static int getAnInt(final int sumToCheck) { | ||
| return sumToCheck % DIVISOR == 0 ? 0 : DIVISOR - (sumToCheck % DIVISOR); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/java/org/fundacionjala/coding/reinaldo/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,32 @@ | ||
| package org.fundacionjala.coding.reinaldo.evaporator; | ||
|
|
||
| /** | ||
| * Created by Administrator on 6/30/2017. | ||
| * | ||
| */ | ||
| final class Evaporator { | ||
|
|
||
| /** | ||
| * This is the constructor of Evaporator. | ||
| */ | ||
| private Evaporator() { | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * this method calc the Evaporator at day. | ||
| * | ||
| * @param cant is the cant | ||
| * @param lost is the lost | ||
| * @param limit is the limit | ||
| * @return int at day | ||
| */ | ||
| static int evaporator(final double cant, final double lost, final double limit) { | ||
| int result = 0; | ||
| do { | ||
| ++result; | ||
| } while (Math.pow(1 - (lost / 100), result) > limit / 100); | ||
|
|
||
| return result; | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
src/main/java/org/fundacionjala/coding/reinaldo/highestAndLowestTest/HighestAndLowest.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,35 @@ | ||
| package org.fundacionjala.coding.reinaldo.highestAndLowestTest; | ||
|
|
||
| import java.util.stream.Stream; | ||
|
|
||
| /** | ||
| * Created by Administrator on 6/30/2017. | ||
| */ | ||
| final class HighestAndLowest { | ||
| /** | ||
| * Private constructor. | ||
| */ | ||
| private HighestAndLowest() { | ||
| } | ||
|
|
||
| /** | ||
| * the method return the highAndLowest. | ||
| * | ||
| * @param numbers highAndLowest test | ||
| * @return String highAndLowest string | ||
| */ | ||
| static String highAndLowest(final String numbers) { | ||
|
|
||
|
|
||
| int high = Stream.of(numbers.split(" ")) | ||
| .mapToInt(Integer::parseInt) | ||
| .max().getAsInt(); | ||
|
|
||
| int low = Stream.of(numbers.split(" ")) | ||
| .mapToInt(Integer::parseInt) | ||
| .min().getAsInt(); | ||
|
|
||
| return String.format("%d %d", high, low); | ||
| } | ||
|
|
||
| } |
85 changes: 85 additions & 0 deletions
85
src/main/java/org/fundacionjala/coding/reinaldo/kataBankOcr/BankOcrKata.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,85 @@ | ||
| package org.fundacionjala.coding.reinaldo.kataBankOcr; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Created by reinaldo on 08/07/2017. | ||
| */ | ||
| final class BankOcrKata { | ||
| private static final int MODULUS_FACTOR = 11; | ||
| private static final int INCREMENT_BY_THREE = 3; | ||
| private static final int TAM_CHARACTERS = 26; | ||
|
|
||
| /** | ||
| * This is the constructor bankOcrKata. | ||
| */ | ||
| private BankOcrKata() { | ||
| } | ||
|
|
||
| /** | ||
| * This method decode a List<String>. | ||
| * | ||
| * @param listAccountNumber listAccount | ||
| * @return String list | ||
| */ | ||
| static String decode(final List<String> listAccountNumber) { | ||
| int charsPerCharacter = INCREMENT_BY_THREE; | ||
| int index = 0; | ||
| StringBuilder accountNumber = new StringBuilder(); | ||
|
|
||
| while (index <= TAM_CHARACTERS) { | ||
|
|
||
| accountNumber.append(EncodedDigit.comparation(getDigitString(listAccountNumber, charsPerCharacter, index))); | ||
| charsPerCharacter += INCREMENT_BY_THREE; | ||
| index += INCREMENT_BY_THREE; | ||
|
|
||
| } | ||
|
|
||
| return accountNumber.toString(); | ||
| } | ||
|
|
||
| /** | ||
| * This method return the a digite in strings for found on map. | ||
| * | ||
| * @param listAccountNumber listAccount | ||
| * @param charsPerCharacter charsper | ||
| * @param index index | ||
| * @return String string | ||
| */ | ||
| private static String getDigitString(final List<String> listAccountNumber, | ||
| final int charsPerCharacter, final int index) { | ||
| return String.format("%s%s%s", | ||
| listAccountNumber.get(0).substring(index, charsPerCharacter), | ||
| listAccountNumber.get(1).substring(index, charsPerCharacter), | ||
| listAccountNumber.get(2).substring(index, charsPerCharacter)); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * @param dateNamber parameter. | ||
| * @return ResultErrIll. | ||
| * this is my constructor 12/03/2017. | ||
| */ | ||
| static String codeCheck(final String dateNamber) { | ||
| return (dateNamber.matches("(.*)[?](.*)") ? "ILL" : (checkSumAcount(dateNamber) != 0) ? "ERR" : "OK"); | ||
| } | ||
|
|
||
| /** | ||
| * @param accountNumber parameter. | ||
| * @return int. | ||
| */ | ||
| static int checkSumAcount(final String accountNumber) { | ||
|
|
||
| int multiplyByNine = 9; | ||
| List<String> listAcountNumber = Arrays.asList(accountNumber.split("")); | ||
| int suma = 0; | ||
|
|
||
| for (String wordItem : listAcountNumber) { | ||
| suma += Integer.parseInt(wordItem) * multiplyByNine--; | ||
| } | ||
|
|
||
| return suma % MODULUS_FACTOR; | ||
| } | ||
|
|
||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/org/fundacionjala/coding/reinaldo/kataBankOcr/Digit.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,8 @@ | ||
| package org.fundacionjala.coding.reinaldo.kataBankOcr; | ||
|
|
||
| /** | ||
| * Created by reinaldo on 12/03/2017. | ||
| */ | ||
| public enum Digit { | ||
| CERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE | ||
| } |
87 changes: 87 additions & 0 deletions
87
src/main/java/org/fundacionjala/coding/reinaldo/kataBankOcr/EncodedDigit.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,87 @@ | ||
| package org.fundacionjala.coding.reinaldo.kataBankOcr; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Iterator; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Created by reinaldo on 08/07/2017. | ||
| */ | ||
| final class EncodedDigit { | ||
| private Map<Integer, String> numberMap; | ||
|
|
||
| /** | ||
| * constructor. | ||
| */ | ||
| private EncodedDigit() { | ||
| numberMap = new HashMap<Integer, String>(); | ||
| fillNumber(); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * method fill number digite. | ||
| */ | ||
| private void fillNumber() { | ||
| numberMap.put(Digit.CERO.ordinal(), | ||
| " _ " | ||
| + "| |" | ||
| + "|_|"); | ||
| numberMap.put(Digit.ONE.ordinal(), | ||
| " " | ||
| + " |" | ||
| + " |"); | ||
| numberMap.put(Digit.TWO.ordinal(), | ||
| " _ " | ||
| + " _|" | ||
| + "|_ "); | ||
| numberMap.put(Digit.THREE.ordinal(), | ||
| " _ " | ||
| + " _|" | ||
| + " _|"); | ||
| numberMap.put(Digit.FOUR.ordinal(), | ||
| " " | ||
| + "|_|" | ||
| + " |"); | ||
| numberMap.put(Digit.FIVE.ordinal(), | ||
| " _ " | ||
| + "|_ " | ||
| + " _|"); | ||
| numberMap.put(Digit.SIX.ordinal(), | ||
| " _ " | ||
| + "|_ " | ||
| + "|_|"); | ||
| numberMap.put(Digit.SEVEN.ordinal(), | ||
| " _ " | ||
| + " |" | ||
| + " |"); | ||
| numberMap.put(Digit.EIGHT.ordinal(), | ||
| " _ " | ||
| + "|_|" | ||
| + "|_|"); | ||
| numberMap.put(Digit.NINE.ordinal(), | ||
| " _ " | ||
| + "|_|" | ||
| + " _|"); | ||
| } | ||
|
|
||
| /** | ||
| * @param lineNumber this is string parameter. | ||
| * @return String. | ||
| */ | ||
| static String comparation(final String lineNumber) { | ||
| EncodedDigit encodedDigit = new EncodedDigit(); | ||
| Iterator<Map.Entry<Integer, String>> it = encodedDigit.numberMap.entrySet().iterator(); | ||
| String resulValue = "?"; | ||
| while (it.hasNext()) { | ||
| Map.Entry<Integer, String> entry = it.next(); | ||
| if (entry.getValue().equalsIgnoreCase(lineNumber)) { | ||
| return entry.getKey().toString(); | ||
|
|
||
| } | ||
| } | ||
|
|
||
| return resulValue; | ||
| } | ||
| } | ||
|
|
||
42 changes: 42 additions & 0 deletions
42
src/main/java/org/fundacionjala/coding/reinaldo/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,42 @@ | ||
| package org.fundacionjala.coding.reinaldo.movies; | ||
|
|
||
| /** | ||
| * Created by Administrator on 3/21/2017. | ||
| */ | ||
| public class Children extends Movie { | ||
| private static final int LIMIT_NEW_CHILD = 3; | ||
| private static final double PRICE = 1.5; | ||
| private static final int NUMBER_RENTAL_DAYS = 1; | ||
|
|
||
| /** | ||
| * * This is the constructor of Children class. | ||
| * | ||
| * @param title title | ||
| */ | ||
| Children(final String title) { | ||
|
|
||
| super(title); | ||
| } | ||
|
|
||
| /** | ||
| * This is the calculateAmount of Children movie. | ||
| * {@inherentDoc} | ||
| */ | ||
|
Contributor
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. This should be /**
* {@inherentDoc}
*/ |
||
| @Override | ||
| public double calculateAmount(final int daysRented) { | ||
| double amount = PRICE; | ||
| if (daysRented > LIMIT_NEW_CHILD) { | ||
| amount += (daysRented - LIMIT_NEW_CHILD) * PRICE; | ||
| } | ||
| return amount; | ||
| } | ||
|
|
||
| /** | ||
| * This is the calculateFrequentRenterPoints of Children movie. | ||
| * {@inherentDoc} | ||
| */ | ||
| @Override | ||
| public int calculateFrequentRenterPoints(final int daysRented) { | ||
| return NUMBER_RENTAL_DAYS; | ||
| } | ||
| } | ||
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.
instead of doing this
please convert a constant the Map
static final