In Java
Assignment 7 B: Battle! For our last assignment in CSE 1321L, we’re going to recreate a basic battle system from a video game. You will create a character and then use it to battle a computer generated opponent. There are three possible classes, with the following attributes: Sword Fighter Unicorn Sorcerer Dance Battler HP: 120 Attack: 40 Defense: 0.20 ClassID: 1 HP: 80 Attack: 35 Defense: 0.60 ClassID: 2 HP: 100 Attack: 20 Defense: 0.42 ClassID: 3 You will create a NPC class that has these three attribute. It should also have an attribute for Name. You will then create the following methods in the NPC class: A constructor that takes in a Name string and a ClassID int. It should use the value of the ClassID to assign values to the other attributes (using the chart above) Getter methods for all five attributes, and a Setter method for HP that subtracts the object’s HP by the value passed in. calculateAttack ◦ This method returns a float value. It takes in a float that represents the opponent’s defense percentage. It should multiply the object’s attack by the inverse of the opponent’s defense percentage, and return that value. For example: 100 * (1 – 0.60) = 40 calculateDefense ◦ This method returns nothing. It takes in a float that represents the opponent’s attack power. It should multiply the opponent’s attack by the inverse of the object’s defense percentage, then subtract 6 additional points from the result. This value should then be subtracted from the object’s HP. isStillAlive ◦ This method returns a boolean value. It should check if the object’s HP is less than or equal to 0. If it is, then return FALSE. Otherwise, return TRUE. You may add other “helper” methods to reduce redundant code, although this is not required. You should then create a driver class, Assignment7B. This program should do the following: Prompt the user for a custom name and what class they want their character to be. You should use this information to create an NPC object. Randomly generate another NPC object to represent the opponent. You can do this by randomly generating the two primitive values, then using them to construct the opponent NPC. Create a loop that runs until one of the opponents runs out of HP. You will first prompt the player to either attack or defend. Then, you will have the opponent randomly choose to either attack or defend. ◦ If both the human and computer player choose to defend, do nothing. ◦ If both of them attack, then call the calculateAttack function on both objects. ◦ If one attacks and one defends, call the calculateDefense function on the defending object. After both choices are made, display messages indicating the actions take and the remaining HP for both sides. When one or both players are defeated, stop the loop and print the results. Sample Output: [Generic RPG Battle System] Enter your name: Morgan Enter your battle class: Unicorn Sorcerer Morgan the Unicorn Sorcerer, your opponent is Brad the Battle Dancer! -Round 1- Do you (a)ttack or (d)efend? a Morgan the Unicorn Sorcerer attacked Brad the Battle Dancer! Brad now has 79.7 HP. Brad the Battle Dancer attacked Morgan the Unicorn Sorcerer! Morgan now has 72 HP. -Round 2- Do you (a)ttack or (d)efend? d Morgan the Unicorn Sorcerer is on guard. Brad the Battle Dancer is on guard. -Round 3- Do you (a)ttack or (d)efend? d Morgan the Unicorn Sorcerer is on guard. Brad the Battle Dancer attacked Morgan the Unicorn Sorcerer! Morgan now has 70 HP. //Skipping ahead to the end of this epic battle (THIS IS NOT PART OF //THE OUTPUT Brad the Battle Dancer was defeated... Morgan the Unicorn Sorcerer wins!
In Java
Trending nowThis is a popular solution!
Step by stepSolved in 9 steps with 8 images
- I need help in improving my Elevator class and it's subclasses code. This is an elevator simulator that uses polymorphism and object-oriented programming to simulate the movement of elevators in a building with multiple types of passengers and elevators. There are 4 types of elevators in the system:StandardElevator: This is the most common type of elevator and has a request percentage of 70%. Standard elevators have a maximum capacity of 10 passengers.ExpressElevator: This type of elevator has a request percentage of 20%. Express elevators have a maximum capacity of 8 passengers and are faster than standard elevators.FreightElevator: This type of elevator has a request percentage of 5%. Freight elevators have a maximum capacity of 5 passengers and are designed to transport heavy items.GlassElevator: This type of elevator has a request percentage of 5%. Glass elevators have a maximum capacity of 6 passengers and are designed to transport fragile item Classes should have this: Elevator {…arrow_forwardI need help in improving my Elevator class and it's subclasses code. This is an elevator simulator that uses polymorphism and object-oriented programming to simulate the movement of elevators in a building with multiple types of passengers and elevators. There are 4 types of elevators in the system:StandardElevator: This is the most common type of elevator and has a request percentage of 70%. Standard elevators have a maximum capacity of 10 passengers.ExpressElevator: This type of elevator has a request percentage of 20%. Express elevators have a maximum capacity of 8 passengers and are faster than standard elevators.FreightElevator: This type of elevator has a request percentage of 5%. Freight elevators have a maximum capacity of 5 passengers and are designed to transport heavy items.GlassElevator: This type of elevator has a request percentage of 5%. Glass elevators have a maximum capacity of 6 passengers and are designed to transport fragile item Classes should have this: Elevator {…arrow_forwardDeeper Class Design - the Square Class In this section, your job will be to write a new class that will adhere to the methods and data outlined in the “members” section below (said another way, your classes will implement a specific set of functions (called an interface) that we’ll describe contractually, ahead of time). These classes will all be shapes, with actions (methods) that are appropriate to shape objects, such as “getArea()”, or “draw()”. First we build a Square class that contains the following data and methods listed below, and then later, we will copy it to quickly make a Circle class. Note: when considering each data item below, think about what type of data would best represent the concept we’re trying to model in our software. For example, all shapes will have a coordinate pair indicating their location in a Cartesian coordinate system. This x and y pair may be modeled as ints or floats, and you might choose between the two depending on what the client application will…arrow_forward
- Let’s assume you are creating a game where multiple players are involved. You will create a Player class that will allow you to later create Player objects. Each player will need a name, a health level, a super power, and number of lives remaining. In your Player class we need the following: Four private data members: name (a String) health (an int) power (a String) lives (an int) Three Constructors: A constructor that has no parameters and sets name to “No Name”, health to 100, power to “Nothing”, and lives to 3.A constructor that takes in two parameters – a String for the name and a String for the power. The health variable should be set to 100 and the lives variable should be set to 3 by default. A constructor that takes in all four parameters and sets them. Accessors and Modifiers (8 total): Create an accessor/getter for all four private data members. Create a modifier/setter for all four private data members. toString() method Create a toString() method that neatly displays the…arrow_forwardI need help in improving my Elevator class and it's subclasses code. This is an elevator simulator that uses polymorphism and object-oriented programming to simulate the movement of elevators in a building with multiple types of passengers and elevators. There are 4 types of elevators in the system:StandardElevator: This is the most common type of elevator and has a request percentage of 70%. Standard elevators have a maximum capacity of 10 passengers.ExpressElevator: This type of elevator has a request percentage of 20%. Express elevators have a maximum capacity of 8 passengers and are faster than standard elevators.FreightElevator: This type of elevator has a request percentage of 5%. Freight elevators have a maximum capacity of 5 passengers and are designed to transport heavy items.GlassElevator: This type of elevator has a request percentage of 5%. Glass elevators have a maximum capacity of 6 passengers and are designed to transport fragile item Classes should have this: Elevator {…arrow_forwardPlease help me with this JAVA exercise. Thank youarrow_forward
- In java language Class Design – Date V0.0 & V1.0 Create a new project for this lab and create a new class inside called Date. If you created a Date class last week, you may use it as a base. What does it mean to be a Date? What data items (called “state”) do you need to keep track of? Alternatively, what does a date have? (“has a” == composition) What can a Date do? What are the actions and verbs that can be applied to a date? Come up with one or two. These become the class’s methods. Try adding 3 data items to your Date to manage the month, day and year. Should these be local variables? Class-level (or instance) variables? Now let’s build a method to set the date This function should take 3 integers as input and assign these to your instance variables declared in the previous step. public void setDate(int m, int d, int y) { And, let’s build a method to report the date This function takes no input and uses the console to output the Date in the format…arrow_forwardThe goal of this coding exercise is to create two classes BookstoreBook and LibraryBook. Both classes have these attributes: author: Stringtiltle: Stringisbn : String- The BookstoreBook has an additional data member to store the price of the book, and whether the book is on sale or not. If a bookstore book is on sale, we need to add the reduction percentage (like 20% off...etc). For a LibraryBook, we add the call number (that tells you where the book is in the library) as a string. The call number is automatically generated by the following procedure:The call number is a string with the format xx.yyy.c, where xx is the floor number that is randomly assigned (our library has 99 floors), yyy are the first three letters of the author’s name (we assume that all names are at least three letters long), and c is the last character of the isbn.- In each of the classes, add the setters, the getters, at least three constructors (of your choosing) and override the toString method (see samplerun…arrow_forwardCreate a new Teller Class Build a new Teller class(“Teller.java”). This class will be a sub-class of Employee. The Teller class should have all the same properties as an Employee as well as two new properties: hoursWorked and shift. HoursWorked is the total hours that this teller worked this week, and shift is either “day” or “evening” shift. Make sure to add 2 constructors and a display() method. Do not include a main() method in the Teller class. Test out this Teller class, by building a separate Tester class called TellerTester stored in a new file called ( “TellerTester.java”. This TellerTester class will only have a main() method, that will instantiate a Teller object, pass all the data to the Teller constructor, and lastly call the Teller display() method; just these 3 lines.arrow_forward
- The atoms of different elements have different numbers of protons, neutrons and electrons. Electrons are negatively charged; protons are positively charged and neutrons have no charge. Write a definition for an atom class that contains: Fields for storing the numbers of protons, neutrons and electrons with appropriate visibility; Setter and getter methods for manipulating these fields, ensuring that the minimum value for electrons and protons is 1, and the minimum value for neutrons is 0; A constructor that initializes new objects of atom to be the smallest element (Hydrogen), for which the number of protons is 1, the number of neutrons is 0, and the number of electrons is 1. Write a new method for the atom class called ision that will return true or false, depending upon whether the atom is an ion. An atom is an ion if it is charged (i.e., if the number of electrons ≠ the number of protons). Write a new method for the atom class called getAtomicMassNumber that will calculate and…arrow_forwardUse the scenario below for help answering 1(A), (B) and (C). This is using Java. The Scenario: You have a class named HeartsPlayer A round of Hearts starts with every player having 13 cards Players then choose 3 cards to “trade” with a player (1st you pass left, 2nd you pass right, 3rd you pass across, 4th you keep) Players then strategically play cards in order to have the lowest score At the end of the round, points are cumulatively totaled for each player. If one player’s total is greater than 100, the game ends and the player with the lowest score wins. Guide: Static & Not Final Field: Accessed by every object, Changing Non-Static & Final Field: Accessed by object itself, Non-Changing Static & Final: Accessed by every object, Non-Changing Non-Static & Not Final Field: Accessed by object itself, Changing 1. How should the following data fields be defined (with respect to final and static)? (a) playerPosition (These have values of North, South, East, or West)- Is…arrow_forwardTHIS NEEDS TO BE DONE IN C#!! The Tourtise and The Hair In this lab, we will be simulating the classic race of the tourtise and the hare. The race will take place on two paths of 70 tiles, which spans from left to right. The path will have two lanes, one for each animal. The path will be represented as an array of 70 characters, where each character will be the following: · A dash(i.e, “-“), which represents an empty tile. · An “h”, which represents the hare on the hare lane. · A “t”, which represents the tourtise on the tortise lane. All tiles will be “empty” (i.e. set to the dash) with the exception of the tiles that are occupied by the animals. As the animals move, the previous tile the animal was on will be set to empty, and the new tile will be changed to either “h” or “t”. Tile 70 will be the finishing tile, and the first animal to that tile will be declared the winner of the race. We will use randomization to determine how far each animal will move. Since this race will be…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education