Alltman
I want an attribute to increment each time an instance is created.
Current output:
Key front door with weight 0,500 kg from level 3 fits on door 1.
There are 2key(s) in circulation.
Key back door with weight 0,500 kg from level 1 fits on door 2.
There are 2 key(s) in circulation.
31 replies
I want an attribute to increment each time an instance is created.
Key front door with weight 0,500 kg from level 3 fits on door 1.
There are 1 key(s) in circulation.
Key back door with weight 0,500 kg from level 1 fits on door 2.
There are 2 key(s) in circulation.
31 replies
I want an attribute to increment each time an instance is created.
Create the domain class "Tool":
-3 properties: name (mandatory, may not be changed), weight (in kg) and level (int)
-constructor with 3 parameters (controls see description setter)
-constructor with 2 parameters. Level is set to 1 by default here.
-getter for each attribute
-setter for the attribute:◦weight: must be a positive number, less than 1000 kg◦level: there are 10 levels in the game, numbered from 1 to 10◦no setter for name because name may not be changed. Name may not be null or empty.
-ToString Object ... with weight ... (3 digits after comma) kg from level ...
Create 2 subclasses:
The class "Weapon":
-2 extra attributes: force and used
-constructor
-getters for the extra attributes
-setter for each extra attribute:◦force: is a positive number◦used: no check needed
-weapons are only available in levels 1 through 5: provide a CheckLevel method for this
-ToString (see below for the requested output)
The class "Key":
-2 extra attributes: door (int), number of the door to which the key fits and numberInOverflow:represents the number of keys present in the game
-constructor
-getters for the extra attributes
-setter for door: must be a positive number
-ToString (see below for the requested output)
-method PastOp: returns true/false depending on the current key on the door given as a parameter fits or not
Cui layer
Write an ObjectApplication in which an array of Weapons and an array of Keys are created. Let the application display the objects created.Possible output:
Weapon colt with weight 1,500 kg from level 3 and with force 6 not yet used.
Weapon brown with weight 0,500 kg from level 1 and with force 23 already used.
Key front door with weight 0,500 kg from level 3 fits on door 1.
There are 1 key(s) in circulation.
Key back door with weight 0,500 kg from level 1 fits on door 2.
There are 2 key(s) in circulation.
31 replies