Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Description Taking that quest to travel deep into the dungeons of a 10,000 year old dragon was probably not your best decision. Nor was coming
Description Taking that quest to travel deep into the dungeons of a 10,000 year old dragon was probably not your best decision. Nor was coming alone with only your laptop and about three hours of battery life. Luckily, since you are an excellent programmer, you can use your code writing skills to conjure up some help! In this exercise, you will write classes for various characters out of a fantasy dungeon exploration game to help you out before you are stuck in the dungeon forever! Directions For this assignment, you will be creating four classes to simulate brave adventurers: one class representing the archetypal adventurer Adventurer.java), one class representing the noble knight (Knight.java), one class representing the feisty archer (Archer.java), and one class to test your code (DungeonDriver.java). You will also javadoc your code for this assignment, so be sure to read the "Checkstyle and Javadocs" section. Adventurer.java This Java file represents an adventurer from the side of good. You should not be able to create an instance of this class. Instance Variables: -Since adventurers are not nameless souls, they should have a name attribute. Adventurers are a secretive bunch, so this variable should be private with no getters or setters. - All adventurers come ready to fight, so include an attack attribute to show their power! Once assigned, the attack value should never change. - No adventurers like to quit, but some are more durable than others, shown by a health attribute - You may include more variables if you'd like in this class Constructors: Include a constructor that takes in name, health, and attack values You should not have any other constructors Methods: Since the dungeon is a confusing and dangerous place, adventurers should be able to attack cach other * Every adventurer has their own unique attack, so this method should be abstract * This method should take in another Adventurer as its only parameter An adventurer should also be able to drink a magical health potion. * This should increase their health by a value of 15 * An adventurer is allowed to have a health value that is higher than their original health value * Even if an adventurer has no health remaining, they can still drink a potion. This is because 0 health doesn't mean they're dead, they're just too exhausted to keep fighting equals method * Override from Object * Two adventurers are equal if they have the same health, attack and name values toString method * Override from Object * Should return "ane: {name}, Health: {health), Attack: [attack}" - Getters and setters as necessary. Remember, do not create gettors or setters for the name attribute. Clase inul follow the rule of encoupulation and abstraction Knight.java This Java file represents a noble knight. A knight is a type of Adventurer and should have all the behaviors of one Instance Variables: - A squire is a knight's helper. Some knights have a squire while others are less fortunate, so knights should have an attribute for the presence of one No other instance variables should be created in Knight . Constructors: A constructor that sets a knight's name, health, attack, and squire existence. - A constructor that takes in a name and assigns the following default values: * Ilealth: 100 * Attack: 15 harSquire: true No other constructors should be created Methods: - A knight is a powerful warrior who can attack with great might * Attack must override the method from Adventurer * If any null parameters are passed in, this method should not do anything * A knight may only attack if they have more than 0 remaining health * If the knight does not have a squire, damage dealt should be equal to the kniglit's attack value. If the knight has a squire, damage sealt should be twice the knight's attack value. * The damage should be inflicted on the defending adventurer's health. If the attack brings the defonding adventurer's health below 0. set it to O instead - A knight should be able to challenge another knight for their squire * This method should take in another knight as its only paramctor * If y null paraneters are passed in, this method should not do anything * A knight can only attempt to steal a squire if the following are trule: the knight has moro than health, the knight doesn't have a squire, :und the other knight (who's being stolen from) does have a squire. The challenge cun still occur i the defending knight las O health When the conditions above are met, the squire-stealing knight makes one attack on the other. If the attacked knight'halih hits D. it. lost its squire. The quirerleading kuigll gula the squire! If the attackod knight's health docsn't hit zero, it should attack the honorloss squire stealing knight in revenge. Don't change any squire attributes in the revenge attuck. Only make one revenge attack. - equals method * Must override Two knights are equal if they have the one healtl, atawk, name and quire values. toString method - Must override * Returns "Name: (name), Health: health}, Attack: [attack), Squire: (true/false}" - Gellers and Sellers as appropriile! Clase must follow the rules of encapsulation and abstraction Archer.java This Java filc represents a stealthy archer. Anerlerin il type of adventurer and should have all the behaviors of on Instance Variables: - Archers always curry surrows, they should love: attribue for how many they currently have. By default, archers carry 10 arrow's. - No other instance variables should be created in Archer Constructors: - A constructor that takes in marne, health, and attack values - A constructor that takes in a name and assigns the following default values: * Health: 75 * Attack: 40 - No other constructors should be created Methods: An archer's attacks their enemies with aid from their bow Attack rusl. Override from Adventurer * If any null parameters are passed in, this method should not do anything All archer is only able to attack if they have at least 1 arrow left and more than health * Damage dealt should be cqual to the archer's attack value * The damage should be inflicted on the defending adventurer's health. If the attack brings the defending adventurer's health below 0, set it to O instead * After the attack, reduce the amount of arrows the archer has by 1 equals method * Must override Two archers are equal if they have the same health, attack and mane values. - toString method Must override * Returns "Nare: (name), Health: health), Attack: [attack), Arrows: (# arrows)" - Gellers and Sellers as appropriate . Class must follow the rules of encapsulation and abstraction DungeonDriver.java This Java file is : driver, meaning it will run the simulation. You can also use it to test your code. Here are some basic tests to get you started with DungeonDriver. These tests are my no means comprehensive, so be sure to create your own! Create a Knight with the following fields: Name="Galalal", Health=7, Attack=1, Squire=true Create a Knight with the following fields: Name-"Lancelot", llealth-30, Attack-5, Squire-falso Create an Archer with the following fiells: Name="Archie", Health=10. Attack=2, Arrows=10 1. Have the Archer Archie attack the Knight Lancelot. After the attack: Archic should have: Namc="Archic", Health=10. Attack=2. Arrows=9 Lancelot should huve: Nanie="Lancelot", Health=28. Attack=i, Squire=re 2. Now have tho Knight Galahad attack the Archer Archie. After the attack: Galalud leuk live: Nalme="Galatul". Health=7. Allack=l, Squire=l.ru Archio should have: Name="Archic", Ilealth=0, Attack2, Arrows 9 3. Have the Archer Archie black the Knight Galalu. Nothing happens, because Archie has Health=0, and so is too tired to attack 4. Have the Knight Lancelot attack the Knight Galahad. After the attack... Galahad should have: Name="Galahad", Health=2, Attack=6, Squire=true Lancelot should have: Namc="Lancelot", Health=28. Attack-8, Squire=false 5. Have the Knight Lancelot challenge the Knight Galahad in an attempt to steal his equire. After the challenge Galaluu slucull live: Nourne="Glaul", Healih=0. Allack=ti, Squire=fullse Lancelot should havo: Name="Lancelot", Health=28. Attack-5, Squiro-truo Description Taking that quest to travel deep into the dungeons of a 10,000 year old dragon was probably not your best decision. Nor was coming alone with only your laptop and about three hours of battery life. Luckily, since you are an excellent programmer, you can use your code writing skills to conjure up some help! In this exercise, you will write classes for various characters out of a fantasy dungeon exploration game to help you out before you are stuck in the dungeon forever! Directions For this assignment, you will be creating four classes to simulate brave adventurers: one class representing the archetypal adventurer Adventurer.java), one class representing the noble knight (Knight.java), one class representing the feisty archer (Archer.java), and one class to test your code (DungeonDriver.java). You will also javadoc your code for this assignment, so be sure to read the "Checkstyle and Javadocs" section. Adventurer.java This Java file represents an adventurer from the side of good. You should not be able to create an instance of this class. Instance Variables: -Since adventurers are not nameless souls, they should have a name attribute. Adventurers are a secretive bunch, so this variable should be private with no getters or setters. - All adventurers come ready to fight, so include an attack attribute to show their power! Once assigned, the attack value should never change. - No adventurers like to quit, but some are more durable than others, shown by a health attribute - You may include more variables if you'd like in this class Constructors: Include a constructor that takes in name, health, and attack values You should not have any other constructors Methods: Since the dungeon is a confusing and dangerous place, adventurers should be able to attack cach other * Every adventurer has their own unique attack, so this method should be abstract * This method should take in another Adventurer as its only parameter An adventurer should also be able to drink a magical health potion. * This should increase their health by a value of 15 * An adventurer is allowed to have a health value that is higher than their original health value * Even if an adventurer has no health remaining, they can still drink a potion. This is because 0 health doesn't mean they're dead, they're just too exhausted to keep fighting equals method * Override from Object * Two adventurers are equal if they have the same health, attack and name values toString method * Override from Object * Should return "ane: {name}, Health: {health), Attack: [attack}" - Getters and setters as necessary. Remember, do not create gettors or setters for the name attribute. Clase inul follow the rule of encoupulation and abstraction Knight.java This Java file represents a noble knight. A knight is a type of Adventurer and should have all the behaviors of one Instance Variables: - A squire is a knight's helper. Some knights have a squire while others are less fortunate, so knights should have an attribute for the presence of one No other instance variables should be created in Knight . Constructors: A constructor that sets a knight's name, health, attack, and squire existence. - A constructor that takes in a name and assigns the following default values: * Ilealth: 100 * Attack: 15 harSquire: true No other constructors should be created Methods: - A knight is a powerful warrior who can attack with great might * Attack must override the method from Adventurer * If any null parameters are passed in, this method should not do anything * A knight may only attack if they have more than 0 remaining health * If the knight does not have a squire, damage dealt should be equal to the kniglit's attack value. If the knight has a squire, damage sealt should be twice the knight's attack value. * The damage should be inflicted on the defending adventurer's health. If the attack brings the defonding adventurer's health below 0. set it to O instead - A knight should be able to challenge another knight for their squire * This method should take in another knight as its only paramctor * If y null paraneters are passed in, this method should not do anything * A knight can only attempt to steal a squire if the following are trule: the knight has moro than health, the knight doesn't have a squire, :und the other knight (who's being stolen from) does have a squire. The challenge cun still occur i the defending knight las O health When the conditions above are met, the squire-stealing knight makes one attack on the other. If the attacked knight'halih hits D. it. lost its squire. The quirerleading kuigll gula the squire! If the attackod knight's health docsn't hit zero, it should attack the honorloss squire stealing knight in revenge. Don't change any squire attributes in the revenge attuck. Only make one revenge attack. - equals method * Must override Two knights are equal if they have the one healtl, atawk, name and quire values. toString method - Must override * Returns "Name: (name), Health: health}, Attack: [attack), Squire: (true/false}" - Gellers and Sellers as appropriile! Clase must follow the rules of encapsulation and abstraction Archer.java This Java filc represents a stealthy archer. Anerlerin il type of adventurer and should have all the behaviors of on Instance Variables: - Archers always curry surrows, they should love: attribue for how many they currently have. By default, archers carry 10 arrow's. - No other instance variables should be created in Archer Constructors: - A constructor that takes in marne, health, and attack values - A constructor that takes in a name and assigns the following default values: * Health: 75 * Attack: 40 - No other constructors should be created Methods: An archer's attacks their enemies with aid from their bow Attack rusl. Override from Adventurer * If any null parameters are passed in, this method should not do anything All archer is only able to attack if they have at least 1 arrow left and more than health * Damage dealt should be cqual to the archer's attack value * The damage should be inflicted on the defending adventurer's health. If the attack brings the defending adventurer's health below 0, set it to O instead * After the attack, reduce the amount of arrows the archer has by 1 equals method * Must override Two archers are equal if they have the same health, attack and mane values. - toString method Must override * Returns "Nare: (name), Health: health), Attack: [attack), Arrows: (# arrows)" - Gellers and Sellers as appropriate . Class must follow the rules of encapsulation and abstraction DungeonDriver.java This Java file is : driver, meaning it will run the simulation. You can also use it to test your code. Here are some basic tests to get you started with DungeonDriver. These tests are my no means comprehensive, so be sure to create your own! Create a Knight with the following fields: Name="Galalal", Health=7, Attack=1, Squire=true Create a Knight with the following fields: Name-"Lancelot", llealth-30, Attack-5, Squire-falso Create an Archer with the following fiells: Name="Archie", Health=10. Attack=2, Arrows=10 1. Have the Archer Archie attack the Knight Lancelot. After the attack: Archic should have: Namc="Archic", Health=10. Attack=2. Arrows=9 Lancelot should huve: Nanie="Lancelot", Health=28. Attack=i, Squire=re 2. Now have tho Knight Galahad attack the Archer Archie. After the attack: Galalud leuk live: Nalme="Galatul". Health=7. Allack=l, Squire=l.ru Archio should have: Name="Archic", Ilealth=0, Attack2, Arrows 9 3. Have the Archer Archie black the Knight Galalu. Nothing happens, because Archie has Health=0, and so is too tired to attack 4. Have the Knight Lancelot attack the Knight Galahad. After the attack... Galahad should have: Name="Galahad", Health=2, Attack=6, Squire=true Lancelot should have: Namc="Lancelot", Health=28. Attack-8, Squire=false 5. Have the Knight Lancelot challenge the Knight Galahad in an attempt to steal his equire. After the challenge Galaluu slucull live: Nourne="Glaul", Healih=0. Allack=ti, Squire=fullse Lancelot should havo: Name="Lancelot", Health=28. Attack-5, Squiro-truo
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started