From 8e3081f24718a67c29172a3b6ef76f53a1b011f5 Mon Sep 17 00:00:00 2001 From: Bowes Date: Tue, 11 Feb 2020 13:17:52 +0000 Subject: [PATCH] Adding method to return the colours supported by GameArena --- GameArena.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/GameArena.java b/GameArena.java index e31ecbd..e1d4f5b 100644 --- a/GameArena.java +++ b/GameArena.java @@ -359,5 +359,18 @@ public boolean spacePressed() return space; } + //NB use lazy instantiation + private String[] names=null; + /** + * Gets the known colour names. + * @return an array of the names of pre-defined colours known by the GameArena + */ + public String[] getDefaultColourNames(){ + if (names==null){ + names = colours.keySet().stream().toArray(String[]::new); + } + return names; + } + }