__init__: Initializes an Wizard object. Takes four parameters: the name of the wizard (a string), their age (an integer), their animal familiar’s name (a string), and their power level (an integer). These are saved in appropriate attributes. In addition, it initializes the following attributes: a Boolean value indicating if the competitor is cursed (initially False ), an integer indicating the number of potions the wizard has (initially 2).
__str__: Returns a string summarizing the Wizard object, following the format below exactly: Merlin with Archimedes the Owl (205 power, 2 potions) You should use values derived from attributes in place of the bolded values.
__lt__: Compares self to another Wizard object. It returns True if self is younger than the other Wizard object, and False otherwise.
get_name: Returns the name of the wizard.
get_power: Returns the wizard’s current power.
add_potion: Increases the number of potions by one. This method has no return value.
drink_potion: If the wizard has a potion, it drinks one (decrementing it from the potions counter) to increase the wizard power by 100 and remove any curse. This method has no return value.
lose_power: Takes one parameter, the amount of power the wizard will lose. The wizard loses this amount of power. If this leaves the wizard with negative power, then the power is set to zero. This method has no return value.
attack: The current wizard attacks a target. Takes another Wizard object as a parameter. Returns a Boolean value indicating if the attack succeeded or failed. If the current wizard is cursed or has less than 100 power, their attack fails. Otherwise, the attack succeeds: they lose 100 power and the other wizard loses 200 power.
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 7 images
- is defined as where a variable is accessible or can be used. Private Class Scope Private Method None of thesearrow_forward1. Dummy GUI Application by Codechum Admin A GUI Application is an application that has a user interface that the user can interact with. For this program, we will be simulating this behavior. First, implement another class called Checkbox which implements the Clickable interface which has only one method: public void click(). The Checkbox will have the following properties: private boolean isChecked (defaults to false upon the creation of object) private String text Additionally, it should have the following methods: the implementation of the click() method If the isChecked is currently false, this will set the isChecked to true and will then print the message "Checkbox is checked". If it is currently true, this will set the isChecked to false and will then print the message "Checkbox is unchecked". Note that the messages to be printed should have also print a new line at the end. an override of the toString() method which returns the message: "Checkbox ({text} - Clicked…arrow_forwardWhen you instantiate an object from a class, you give a name to this particular object so that your program can distinguish it from other objects you instantiate from the same class. True Falsearrow_forward
- Help me With this Java Taskarrow_forward9arrow_forwardInstructions: IMPORTANT: This is a continuation of the previous part of the project and assumes that you are starting with code that fulfills all requirements from that part of the project. Modify the your code from the previous part of the project to make it modular. In addition to the main method, your code must include the following static methods: Method 1 - displayTitle A method that creates a String object in memory to hold the text “Computer Hardware Graphics Quality Recommendation Tool” and displays it Method 2 – getResolutionString A method that accepts an integer value (1, 2, 3, or 4) that denotes the monitor resolution. The method should return the appropriate String representation of the monitor resolution. For example, if the method is passed an integer value of 1, it should return a String with a value of “1280 x 720”. (See Step 4 of Project 1) Method 3 – getMultiplierValue A method that accepts an integer value (1, 2, 3, or 4) that denotes the monitor resolution and…arrow_forward
- T/F 2. Formal parameters are those that appear in the method call and actual parameters are those that appear in the method header.arrow_forwardA method to find a set of value of instance variable Choose one Accessor method Reference method Getter method Mutator methodarrow_forwardpublic class Accumulator { private int total private String name; public Accummulator (string name , int total) { this .name = name; this .total=total; } } 3. In a main method, create an object of Accumulator with the name as "Mary" and total as 100.arrow_forward
- In python and include doctring: First, write a class named Movie that has four data members: title, genre, director, and year. It should have: an init method that takes as arguments the title, genre, director, and year (in that order) and assigns them to the data members. The year is an integer and the others are strings. get methods for each of the data members (get_title, get_genre, get_director, and get_year). Next write a class named StreamingService that has two data members: name and catalog. the catalog is a dictionary of Movies, with the titles as the keys and the Movie objects as the corresponding values (you can assume there aren't any Movies with the same title). The StreamingService class should have: an init method that takes the name as an argument, and assigns it to the name data member. The catalog data member should be initialized to an empty dictionary. get methods for each of the data members (get_name and get_catalog). a method named add_movie that takes a Movie…arrow_forwardFor your homework assignment, build a simple application for use by a local retail store. Your program should have the following classes: Item: Represents an item a customer might buy at the store. It should have two attributes: a String for the item description and a float for the price. This class should also override the __str__ method in a nicely formatted way. Customer: Represents a customer at the store. It should have three attributes: a String for the customer's name, a Boolean for the customer's preferred status, and a list of 5 indexes to hold Item objects. Include the following methods: make_purchase: accepts a String and a double as parameters to represent the name and price of an item this customer is purchasing. Create a new Item object with this info and append it to the internal list. If the customer is a preferred customer based on the Boolean attribute's value, take 10% off the total sale price. __str__: Override this method to print the customer's name and every…arrow_forwardWhen a method call parameter is preceded by the word "out" in a piece of programming code, what does this imply?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