From 005df941149846872e70e1861c482ee6e13af637 Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Mon, 2 Dec 2024 19:55:18 +0100 Subject: [PATCH] added Resources calss to access teh properties --- .../src/main/java/pp/mdga/Resources.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/Resources.java diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/Resources.java b/Projekte/mdga/model/src/main/java/pp/mdga/Resources.java new file mode 100644 index 00000000..a8c3bf82 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/Resources.java @@ -0,0 +1,33 @@ +package pp.mdga; + +import java.util.ResourceBundle; + +/** + * Provides access to the resource bundle of the game. + * + * @see #BUNDLE + */ +public class Resources { + /** + * The resource bundle for the MDGA game. + */ + public static final ResourceBundle BUNDLE = ResourceBundle.getBundle("mdga"); //NON-NLS + + /** + * Gets a string for the given key from the resource bundle in {@linkplain #BUNDLE}. + * + * @param key the key for the desired string + * @return the string for the given key + * @throws NullPointerException if {@code key} is {@code null} + * @throws java.util.MissingResourceException if no object for the given key can be found + * @throws ClassCastException if the object found for the given key is not a string + */ + public static String lookup(String key) { + return BUNDLE.getString(key); + } + + /** + * Private constructor to prevent instantiation. + */ + private Resources() { /* do not instantiate */ } +}