I want an attribute to increment each time an instance is created.
Everytime a new instance of Sleutel is made I want the _aantalInOmloop to increment.
16 Replies
Marked numbers is what the output should be
Make the
_antalOolOop
static
and increment it in the ctor
Ah, you already have it this way
Well, it should work, thenAngius
REPL Result: Success
Result: int
Compile: 451.997ms | Execution: 58.490ms | React with ❌ to remove this embed.
Like so
like this
A sleutel is a key btw
but output is still key one... there are 2 keys, key two... there are 2 keys
it needs to be key one... there is 1 key, key 2 ... there are 2 keys
Output? Keys? What do you mean?
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.
this is the assignment
Expected output:
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.
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.
If you print all of that output after creating two keys, then that's how it'll look
But still, not sure why you even need that property
Why not just... keep the keys in a list?
And count how many keys are in that list?
That would be easy but sadly enough that's not the assignment 😦
Write an ObjectApplication in which an array of Weapons and an array of Keys are created.Isn't it?
What is the command again to send my code?
I will do it likethat
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/BlazeBin - puycivpuvdxa
A tool for sharing your source code with the world!