From 839beb29daf492e3c19c4bcfe0df9bf814a04e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Mon, 27 May 2024 08:29:58 +0300 Subject: [PATCH] docs: update property --- property/README.md | 47 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/property/README.md b/property/README.md index ad2dc90fc..b13f8fb89 100644 --- a/property/README.md +++ b/property/README.md @@ -79,7 +79,7 @@ public enum Type { } ``` -In the main method, we create a prototype character and then create different types of characters based on the prototype: +In the `main` method, we create a prototype character and then create different types of characters based on the prototype: ```java public static void main(String[] args) { @@ -112,12 +112,49 @@ public static void main(String[] args) { } ``` +Program output: + +``` +08:27:52.567 [main] INFO com.iluwatar.property.App -- Player: Player_1 +Character type: MAGE +Stats: + - AGILITY:10 + - STRENGTH:10 + - ATTACK_POWER:10 + - ARMOR:8 + - INTELLECT:15 + - SPIRIT:10 + +08:27:52.569 [main] INFO com.iluwatar.property.App -- Player: Player_2 +Character type: WARRIOR +Stats: + - AGILITY:10 + - STRENGTH:10 + - ATTACK_POWER:10 + - ARMOR:15 + - RAGE:15 + +08:27:52.569 [main] INFO com.iluwatar.property.App -- Player: Player_3 +Character type: ROGUE +Stats: + - AGILITY:15 + - STRENGTH:10 + - ATTACK_POWER:10 + - ARMOR:10 + - ENERGY:15 + +08:27:52.569 [main] INFO com.iluwatar.property.App -- Player: Player_4 +Character type: ROGUE +Stats: + - AGILITY:15 + - STRENGTH:10 + - ATTACK_POWER:12 + - ARMOR:10 + - ENERGY:15 +``` + This way, we can easily create new characters with different properties without having to create a new class for each type of character. -## Class diagram - -![Property](./etc/property.png "Property") - ## Applicability Use the Property pattern when