From a26b768b9490d12fec2e2e9fe4631fabdf9b29ba Mon Sep 17 00:00:00 2001 From: Arthur Bols Date: Mon, 26 Feb 2018 15:54:01 +0100 Subject: [PATCH] begin of worm class --- src/Worm.java | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/Worm.java b/src/Worm.java index d1b7c78..795c8d9 100644 --- a/src/Worm.java +++ b/src/Worm.java @@ -1,4 +1,58 @@ public class Worm { + // Location + private double coordX; + private double coordY; + + // Orientation + private double orientation; + + // shape + private double radius; + private double minRadius; + // mass + private double mass; + + // points + private double points; + + // name + private final String name; + + public Worm(double coordX, double coordY, double orientation, String name, double radius) throws IllegalArgumentException { + + this.coordX = coordX; + this.coordY = coordY; + this.orientation = orientation; + this.radius = radius; + this.minRadius = 0.25; + this.name = name; + } + + public Worm(double coordX, double coordY, double orientation, String name, double radius, double minRadius) throws IllegalArgumentException { + this.coordX = coordX; + this.coordY = coordY; + this.orientation = orientation; + this.radius = radius; + this.minRadius = minRadius; + this.name = name; + } + + private boolean isValidName (String name) { + + if (name.length() < 2 || !Character.isUpperCase(name.charAt(0))) { + return false; + } + //char allowedCharacters[] = {'\'', '"', ' '}; + Set allowedCharacters[] = new + for (int i = 0; i < name.length(); i++) { + if (!Character.isLetter(name.charAt(i))) { + if (!allowedCharacters.contains() name.charAt(i)) + } + } + + + return false; + } }