Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Collection;
- import java.util.HashMap;
- import java.util.Map.Entry;
- public class Komunikaty {
- private static HashMap<Integer, HashMap<Integer, String>> komunikaty = new HashMap<>();
- static {
- komunikaty.put(0, new HashMap<>()); //polski
- komunikaty.put(1, new HashMap<>()); //angielski
- }
- public static void dodaj(int język, int id, String s) {
- if(!komunikaty.containsKey(język))
- komunikaty.put(język, new HashMap<>());
- komunikaty.get(język).put(id, s);
- }
- public static String tłumacz(String s, int językDocelowy) {
- Collection<HashMap<Integer, String>> zestawyJęzykowe = komunikaty.values();
- for(HashMap<Integer, String> zestaw : zestawyJęzykowe) {
- for(Entry<Integer, String> komunikat : zestaw.entrySet()) {
- if(komunikat.getValue().equals(s)) {
- int idKomunikatu = komunikat.getKey();
- return komunikaty.get(językDocelowy).get(idKomunikatu);
- }
- }
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement