-
Notifications
You must be signed in to change notification settings - Fork 10
Katanorman #30
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
666nonak666
wants to merge
9
commits into
AT-03:develop
Choose a base branch
from
666nonak666:katanorman
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
Katanorman #30
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
72e3f6d
prueba task 1and 2
666nonak666 021b19d
refactor calculateAmount
666nonak666 60e9168
exam passed test cases
666nonak666 58ad1da
Update Kata.java
666nonak666 7e3d84d
Update Children.java
666nonak666 6844421
Update Regular.java
666nonak666 b3a63de
Merge branch 'develop' of https://github.com/AT-03/coding into develop
666nonak666 d8ddf27
fixed with package the Pablo and Ruber.
666nonak666 80f5d9b
test release
666nonak666 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
30 changes: 30 additions & 0 deletions
30
src/main/java/org/fundacionjala/coding/norman/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,30 @@ | ||
| package org.fundacionjala.coding.norman.average; | ||
|
|
||
| import java.util.stream.IntStream; | ||
|
|
||
| /** | ||
| * Created by NORMAN on 2/7/2017. | ||
| */ | ||
| public final class Average { | ||
| /** | ||
| * Contructor. | ||
| */ | ||
| private Average() { | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * average to array. | ||
| * | ||
| * @param numbers array. | ||
| * @return array. | ||
| */ | ||
|
|
||
| public static double[] averages(final int[] numbers) { | ||
| return (numbers == null || numbers.length <= 1) | ||
| ? new double[]{} | ||
| : IntStream.range(0, numbers.length - 1) | ||
| .mapToDouble(i -> (numbers[i] + numbers[i + 1]) / 2.0) | ||
| .toArray(); | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/org/fundacionjala/coding/norman/banck_ocr/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.norman.banck_ocr; | ||
|
|
||
| /** | ||
| * Created by NORMAN on 2/7/2017. | ||
| */ | ||
| public enum Digit { | ||
| CERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE | ||
| } |
84 changes: 84 additions & 0 deletions
84
src/main/java/org/fundacionjala/coding/norman/banck_ocr/FileNumberBankOcr.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,84 @@ | ||
| package org.fundacionjala.coding.norman.banck_ocr; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Iterator; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Created by NORMAN on 2/7/2017. | ||
| */ | ||
| public class FileNumberBankOcr { | ||
| private Map<Integer, String> numberMap; | ||
|
|
||
| /** | ||
| * constructor. | ||
| */ | ||
| FileNumberBankOcr() { | ||
| numberMap = new HashMap<Integer, String>(); | ||
| fillNumber(); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * method fill number digite. | ||
| */ | ||
| public 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. | ||
| */ | ||
| public String comparation(final String lineNumber) { | ||
| Iterator<Map.Entry<Integer, String>> it = numberMap.entrySet().iterator(); | ||
| String resulValue = "?"; | ||
| while (it.hasNext()) { | ||
| Map.Entry<Integer, String> entry = it.next(); | ||
| if (entry.getValue().toString().equalsIgnoreCase(lineNumber)) { | ||
| resulValue = entry.getKey().toString(); | ||
| } | ||
| } | ||
|
|
||
| return resulValue; | ||
| } | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
src/main/java/org/fundacionjala/coding/norman/banck_ocr/HistoryOneBankOcr.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,29 @@ | ||
| package org.fundacionjala.coding.norman.banck_ocr; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Created by NORMAN on 2/7/2017. | ||
| */ | ||
| public class HistoryOneBankOcr extends FileNumberBankOcr { | ||
|
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. @AT-03/at-03 |
||
| /** | ||
| * This is my constructor BankOCR. | ||
| */ | ||
| public HistoryOneBankOcr() { | ||
| super(); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * @param lines this is mi data insert lines. | ||
| * @return String return string in format digit. | ||
| * change y | ||
| */ | ||
| public String verificationLineNumber(final List<String> lines) { | ||
| StringBuilder resulta = new StringBuilder(); | ||
| for (String line : lines) { | ||
| resulta.append(super.comparation(line)); | ||
| } | ||
| return resulta.toString(); | ||
| } | ||
| } | ||
23 changes: 23 additions & 0 deletions
23
src/main/java/org/fundacionjala/coding/norman/banck_ocr/HistoryThreeErrFall.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,23 @@ | ||
| package org.fundacionjala.coding.norman.banck_ocr; | ||
|
|
||
| /** | ||
| * Created by NORMAN on 2/7/2017. | ||
| */ | ||
| public class HistoryThreeErrFall extends HistoryTwoChecksum { | ||
|
|
||
| /** | ||
| * this is my constructor 12/03/2017. | ||
| */ | ||
| public HistoryThreeErrFall() { | ||
| super(); | ||
| } | ||
|
|
||
| /** | ||
| * @param dateNamber parameter. | ||
| * @return ResultErrIll. | ||
| * this is my constructor 12/03/2017. | ||
| */ | ||
| public String verificateNumber(final String dateNamber) { | ||
| return (dateNamber.matches("(.*)[?](.*)") ? "ILL" : (checkSumAcount(dateNamber) != 0) ? "ERR" : "OK"); | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/org/fundacionjala/coding/norman/banck_ocr/HistoryTwoChecksum.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.norman.banck_ocr; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Created by NORMAN on 2/7/2017. | ||
| */ | ||
| public class HistoryTwoChecksum extends FileNumberBankOcr { | ||
|
|
||
| private int multiplyByNine = 9; | ||
| private static final int MODULUS_FACTOR = 11; | ||
|
|
||
| /** | ||
| * HistoryTwoChecksum. | ||
| */ | ||
| public HistoryTwoChecksum() { | ||
| super(); | ||
| } | ||
|
|
||
| /** | ||
| * @param accountNumber parameter. | ||
| * @return int. | ||
| */ | ||
| public int checkSumAcount(final String accountNumber) { | ||
| List<String> listaCadena = Arrays.asList(accountNumber.split("")); | ||
| int suma = 0; | ||
| for (String dato : listaCadena) { | ||
| suma += Integer.parseInt(dato) * multiplyByNine--; | ||
| } | ||
| return suma % MODULUS_FACTOR; | ||
|
|
||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/fundacionjala/coding/norman/eanvalidator/EANValidator.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,40 @@ | ||
| package org.fundacionjala.coding.norman.eanvalidator; | ||
|
|
||
| /** | ||
| * Created by NORMAN on 2/7/2017. | ||
| */ | ||
| public final class EANValidator { | ||
| private static final int ODD_DIGIT_MULTIPLIER = 3; | ||
| private static final int DIVISIBILITY_FACTOR = 10; | ||
|
|
||
| /** | ||
| * Constructor private. | ||
| */ | ||
|
|
||
| private EANValidator() { | ||
| } | ||
|
|
||
| /** | ||
| * Takes an string number to verify it is checksum it's correct. | ||
| * | ||
| * @param eAN String number with exactly 13 digits. | ||
| * @return true if the checksum is ok. | ||
| */ | ||
|
|
||
| static boolean validate(final String eAN) { | ||
| int sum = 0; | ||
|
|
||
|
|
||
| for (int i = 1; i < eAN.length(); i++) { | ||
| int numericValue = Character.getNumericValue(eAN.charAt(i - 1)); | ||
| sum += i % 2 == 0 ? numericValue * ODD_DIGIT_MULTIPLIER : numericValue; | ||
| } | ||
|
|
||
| int module = sum % DIVISIBILITY_FACTOR; | ||
| int check = module != 0 ? DIVISIBILITY_FACTOR - module : 0; | ||
|
|
||
| return check == Character.getNumericValue(eAN.charAt(eAN.length() - 1)); | ||
|
|
||
| } | ||
|
|
||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/org/fundacionjala/coding/norman/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.norman.evaporator; | ||
|
|
||
| /** | ||
| * Created by NORMAN on 2/7/2017. | ||
| */ | ||
| public final class Evaporator { | ||
|
|
||
| private static final int INT = 100; | ||
|
|
||
| /** | ||
| * Contructor. | ||
| */ | ||
| private Evaporator() { | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * method calculate time in days when evaporate the liquid. | ||
| * | ||
| * @param cant cant of liquid. | ||
| * @param porcentaje porcentage evaporation. | ||
| * @param umbral limit the evaporation in porcentage. | ||
| * @return cant days. | ||
| */ | ||
| public static int evaporator(final double cant, final double porcentaje, final double umbral) { | ||
| int res = 0; | ||
| double aux = INT; | ||
| while (aux > umbral) { | ||
| aux -= porcentaje * aux / INT; | ||
| res++; | ||
| } | ||
| return res; | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/main/java/org/fundacionjala/coding/norman/highestandlowest/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,30 @@ | ||
| package org.fundacionjala.coding.norman.highestandlowest; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.stream.Stream; | ||
|
|
||
| /** | ||
| * Created by NORMAN on 2/7/2017. | ||
| */ | ||
| public final class HighestAndLowest { | ||
| /** | ||
| * Private constructor. | ||
| */ | ||
| private HighestAndLowest() { | ||
| } | ||
|
|
||
| /** | ||
| * The method return the highest and lowest value of a number array. | ||
| * | ||
| * @param numbers is the String of numbers. | ||
| * @return a String with the highest and lowest values. | ||
| */ | ||
| static String highAndLowest(final String numbers) { | ||
|
|
||
|
|
||
| int[] digits = Stream.of(numbers.split(" ")).mapToInt(Integer::parseInt).toArray(); | ||
| Arrays.sort(digits); | ||
|
|
||
| return String.format("%d %d", digits[digits.length - 1], digits[0]); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/java/org/fundacionjala/coding/norman/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,32 @@ | ||
| package org.fundacionjala.coding.norman.movies; | ||
|
|
||
| /** | ||
| * Created by NORMAN on 2/7/2017. | ||
| */ | ||
| public class Children extends Movie { | ||
| private static final int LIMIT_DAYS_TO_RENT_CHILDREN_MOVIE = 3; | ||
| private static final double NO_RELEASE_MOVIE_FEE = 1.5; | ||
|
|
||
| /** | ||
| * Children constructor. | ||
| * | ||
| * @param title of String type. | ||
| */ | ||
| Children(final String title) { | ||
| super(title); | ||
| } | ||
|
|
||
| @Override | ||
| public double calculateAmount(final int daysRented) { | ||
| double amount = NO_RELEASE_MOVIE_FEE; | ||
| if (daysRented > LIMIT_DAYS_TO_RENT_CHILDREN_MOVIE) { | ||
| amount += (daysRented - LIMIT_DAYS_TO_RENT_CHILDREN_MOVIE) * NO_RELEASE_MOVIE_FEE; | ||
| } | ||
| return amount; | ||
| } | ||
|
|
||
| @Override | ||
| public int calculateFrequentRenterPoints(final int daysRented) { | ||
| return 1; | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
@666nonak666
Instead of having this method
you can have a static attribute.
Review again