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 2 classes: AggressiveWarrior and DefensiveWarrior.
Warriors have 3 attributes, all integers (int): level, attack, and defense. Level is required, while attack
and defense are optional.
Aggressive warriors have a default attack of 3 and a default defense of 2.
Defensive warriors have a default attack of 2 and a default defense of 3.
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!