Question: Use the Builder design pattern to create 2 classes: AggressiveWarrior and DefensiveWarrior. Warriors have 3 attributes, all integers ( int ) : level, attack, and
Use the Builder design pattern to create 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
Warriors must be immutable.
The order of things matters in your class:
Fields
Constructor
Methods
Builder
Builder fields
Builder Constructor
Builder methods
Builder build
Using default visibility is fine where private does not seem to fit. Always try private first, then increase
visibility as needed.
Validation: negative values for level, attack, and defense are all invalid. There are tests for this. Provide the code
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
