diff --git a/src/main/java/com/booleanuk/Scrabble.java b/src/main/java/com/booleanuk/Scrabble.java index 88108a8..e6cfb31 100644 --- a/src/main/java/com/booleanuk/Scrabble.java +++ b/src/main/java/com/booleanuk/Scrabble.java @@ -1,12 +1,97 @@ package com.booleanuk; + +import java.util.*; + public class Scrabble { - public Scrabble(String word) { + private final String word; + public Scrabble(String word) { + this.word = word; } public int score() { - return -1; - } + if(this.word == null || this.word.isEmpty() || this.word.isBlank() || this.word.equals("\n\r\t\b\f")) + return 0; + + //Tildeler poeng til vær bokstav + List group1 =List.of('A','E','I','U','O','U','L','N','R','S','T'); + Listgroup2 = List.of('D', 'G'); + List group3 =List.of('B', 'C', 'M', 'P'); + List group4 =List.of('F', 'H', 'V', 'W', 'Y'); + List group5 = List.of('K'); + List group8 = List.of('J', 'X'); + List group10 =List.of('Q', 'Z'); + List group11 =List.of('{', '}','[',']'); + List group12 =List.of('!','|','#'); + + HashMap map = new HashMap<>(); + group1.forEach(x-> map.put(x,1)); + group2.forEach(x-> map.put(x,2)); + group3.forEach(x-> map.put(x,3)); + group4.forEach(x-> map.put(x,4)); + group5.forEach(x-> map.put(x,5)); + group8.forEach(x-> map.put(x,8)); + group10.forEach(x-> map.put(x,10)); + + int count = 0; + //Deler opp word i bokstaver + char[] bokstaver = this.word.toUpperCase().toCharArray(); + HashMap bracketMap = new HashMap<>(); + + for (int i = 0; i