|
| 1 | +package week2; |
| 2 | + |
| 3 | +import java.util.Map; |
| 4 | + |
| 5 | +public class TextAnalyzer { |
| 6 | + |
| 7 | + // Sõned, mis lõppevad tähtedega "ed" või mõni täht veel. |
| 8 | + // (Ülesanne lehel on pikemalt seletatud!) |
| 9 | + public static final String RE1 = null; |
| 10 | + |
| 11 | + // Paaritu pikkusega sõned. |
| 12 | + public static final String RE2 = null; |
| 13 | + |
| 14 | + // Sõned, mille esimene ja viimane täht on sama! |
| 15 | + public static final String RE3 = null; |
| 16 | + |
| 17 | + // Sõned, mis ülesanne nimede tingimustele vastavad. |
| 18 | + public static final String NAME = null; |
| 19 | + |
| 20 | + // Sõned, mis ülesanne numbri tingimustele vastavad. |
| 21 | + public static final String NUMBER = null; |
| 22 | + |
| 23 | + public TextAnalyzer(String text) { |
| 24 | + // Kas siin peaks ka midagi tegema? |
| 25 | + } |
| 26 | + |
| 27 | + public Map<String, String> getPhoneNumbers() { |
| 28 | + throw new UnsupportedOperationException(); |
| 29 | + } |
| 30 | + |
| 31 | + public String anonymize() { |
| 32 | + throw new UnsupportedOperationException(); |
| 33 | + } |
| 34 | + |
| 35 | + |
| 36 | + static void main() { |
| 37 | + |
| 38 | + String input = |
| 39 | + """ |
| 40 | + Mina olen Kalle Kulbok ja mu telefoninumber on 5556 4272. |
| 41 | + Mina olen Peeter Peet ja mu telefoninumber on 5234 567. |
| 42 | + Mari Maasikas siin, mu number on 6723 3434. Tere, olen Jaan Jubin numbriga 45631643."""; |
| 43 | + |
| 44 | + TextAnalyzer ta = new TextAnalyzer(input); |
| 45 | + Map<String, String> phoneBook = ta.getPhoneNumbers(); |
| 46 | + System.out.println(phoneBook.get("Peeter Peet")); // peab väljastama 5234567 |
| 47 | + System.out.println(phoneBook.get("Jaan Jubin")); // peab väljastama 45631643 |
| 48 | + |
| 49 | + System.out.println(ta.anonymize()); |
| 50 | + |
| 51 | + /* peab väljastama: |
| 52 | + Mina olen <nimi> ja mu telefoninumber on <telefoninumber>. |
| 53 | + Mina olen <nimi> ja mu telefoninumber on <telefoninumber>. |
| 54 | + <nimi> siin, mu number on <telefoninumber>. Tere, olen <nimi> numbriga <telefoninumber>. |
| 55 | + */ |
| 56 | + } |
| 57 | +} |
0 commit comments