From 9a5c68f0324cf146deda21c4d363388fee772e7f Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Wed, 7 Mar 2018 19:43:53 +0100 Subject: [PATCH] Commentaar ivm name --- OGP1718-Worms/src/Worm.java | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/OGP1718-Worms/src/Worm.java b/OGP1718-Worms/src/Worm.java index 144ea1c..5696849 100644 --- a/OGP1718-Worms/src/Worm.java +++ b/OGP1718-Worms/src/Worm.java @@ -287,11 +287,26 @@ public class Worm { // region name //=================================================================================== - + + /** + * Return the name of the worm + * the name of the worm expresses the identity of the worm + */ public String getName() { return this.name; } + /** + * set the name of the worm tot the given name + * + * @param name + * the new name for the worm + * @post the new name of the worm is equal to the given name + * |new.GetName() == name + * @throws IllegalNameException(validName, name) + * the given name is not a valid name for any worm + * |! isValidName(name) + */ public void setName(String name) { int validName = isValidName(name); @@ -302,8 +317,17 @@ public class Worm { } /** - * @param name ... - * @return ... + * check whether the given name is a valid name for all worms + * + * @param name + * the name to check + * @return -1 if and only if the given name is longer then 2, + * the first letter is uppercase and the name only exists + * of letters, " ", " ' " and " "" " + * |for (i = 0; i < name.length(); i++) + * |result == (name.length() > 2 && Character.isUpperCase(name.charAt(0) + * |&& Character.isLetter(name.charAt(i)) && + * |allowedCharacters.indexOf(name.charAt(i))) */ private int isValidName (String name) {