import java.util.regex.Pattern; public class Ranking{ public static int getPoints(String[] matches, boolean isHomeMatch) { int points = 0; if(matches.length!=10) { return -1; } for (int i = 0; i < matches.length; i++) { if(matches[i]==null) { return -1; } if (!Pattern.matches("^[0-9]+[-]{1}[0-9]+$", matches[i])) { return -1; } String[] actualMatch = matches[i].split("-"); if (!isHomeMatch) { String aux = actualMatch[0]; actualMatch[0] = actualMatch[1]; actualMatch[1] = aux; } if (Integer.parseInt(actualMatch[0]) > Integer.parseInt(actualMatch[1])) { points += 3; } else if (Integer.parseInt(actualMatch[0]) == Integer.parseInt(actualMatch[1])) { points += 1; } isHomeMatch = !isHomeMatch; } return points; } }
- import java.util.regex.Pattern;
- public class Ranking{
- public static int getPoints(String[] matches, boolean isHomeMatch) {
- int points = 0;
- if(matches.length!=10) {
- return -1;
- }
- for (int i = 0; i < matches.length; i++) {
- if(matches[i]==null) {
- return -1;
- }
- if (!Pattern.matches("^[0-9]+[-]{1}[0-9]+$", matches[i])) {
- return -1;
- }
- String[] actualMatch = matches[i].split("-");
- if (!isHomeMatch) {
- String aux = actualMatch[0];
- actualMatch[0] = actualMatch[1];
- actualMatch[1] = aux;
- }
- if (Integer.parseInt(actualMatch[0]) > Integer.parseInt(actualMatch[1])) {
- points += 3;
- } else if (Integer.parseInt(actualMatch[0]) == Integer.parseInt(actualMatch[1])) {
- points += 1;
- }
- isHomeMatch = !isHomeMatch;
- }
- return points;
- }
- }
import java.util.regex.Pattern; public class Ranking{ public static int getPoints(String[] matches, boolean isHomeMatch) { int points = 0; if(matches.length!=12) { return -1; } for (int i = 0; i < matches.length; i++) { if (!Pattern.matches("^[0-9]+[-]{1}[0-9]+$", matches[i])) { return -1; } String[] actualMatch = matches[i].split("-"); if (!isHomeMatch) { String aux = actualMatch[0]; actualMatch[0] = actualMatch[1]; actualMatch[1] = aux; } if (Integer.parseInt(actualMatch[0]) > Integer.parseInt(actualMatch[1])) { points += 3; } else if (Integer.parseInt(actualMatch[0]) == Integer.parseInt(actualMatch[1])) { points += 1; } isHomeMatch = !isHomeMatch; } return points; } }
public class Ranking{}- import java.util.regex.Pattern;
- public class Ranking{
- public static int getPoints(String[] matches, boolean isHomeMatch) {
- int points = 0;
- if(matches.length!=12) {
- return -1;
- }
- for (int i = 0; i < matches.length; i++) {
- if (!Pattern.matches("^[0-9]+[-]{1}[0-9]+$", matches[i])) {
- return -1;
- }
- String[] actualMatch = matches[i].split("-");
- if (!isHomeMatch) {
- String aux = actualMatch[0];
- actualMatch[0] = actualMatch[1];
- actualMatch[1] = aux;
- }
- if (Integer.parseInt(actualMatch[0]) > Integer.parseInt(actualMatch[1])) {
- points += 3;
- } else if (Integer.parseInt(actualMatch[0]) == Integer.parseInt(actualMatch[1])) {
- points += 1;
- }
- isHomeMatch = !isHomeMatch;
- }
- return points;
- }
- }