Question: In Java, use the Builder design pattern to create a Warrior classes: AggressiveWarrior and DefensiveWarrior. Warriors have 3 attributes, all integers ( int ) :
In Java, use the Builder design pattern to create a Warrior classes: AggressiveWarrior and DefensiveWarrior.
Warriors have attributes, all integers int: level, attack, and defense. Level is required, while attack
and defense are optional.
Aggressive warriors have a default attack of and a default defense of
Defensive warriors have a default attack of and a default defense of
Note that during the creation of either Aggressive or Defensive Warriors, the default value can be changed.
Warriors must be immutable.
The order of things matters in your class:
Fields
Constructor
Methods
Builder
Builder fields
Builder Constructor
Builder methods
Builder build Finally demonstrate in the main method the successful creation of warriors. Where are of level with base stats, and the other demonstrating the ability of overwriting the default stats.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
