Java code. You will need to make classes that could be used to stage a battle as described below.
You have been tasked to create a number of items that can be used in an online game. All items can be used on a game character who will have a name, a number of health-points and a bag to hold the items.
Here are examples of items that can be made:
| Item | type of item | effectOnHealth | other info |
|---|---|---|---|
| Widow's Cloak | Armor | +15 | |
| Gladiator's Shield | Armor | +8 | |
| Rusty Knife | Weapon | -3 | |
| Protection Spell | Spell | 1 | has magic words that can be read |
| Note from Zelda | Letter | 0 | says "Beware of the Witch" |
Here are examples of characters that can be made:
| name | health points |
|---|---|
| Godwin | 30 |
| Marilyn | 40 |
All items can be added to any character's bag and also used on any character. (For instance the Rusty Knife could be used on a character to lower their health by 3 points.)
Armor and weapons can be equipped (worn) and removed. Spells can also be equipped (memorized) which casts a glow around the character and removed (forgotten) which removes the glow. In the future, any time a character equips or removes any item, their appearance will be altered. These methods -- for now -- can just have a body which says either "equipping" or "removing."
Both spells and letters have some text that could be read. Whenever a spell or letter is used, the text will also be read (displayed). However these items can be read independently from their use on a character.
Build these items using good interface and abstract class design as appropriate. Set the toString() method of the Character class to return a character's name and current health. You should have a good object oriented structure and good method signatures.
To illustrate this, in a driver class, two characters, Godwin and Marilyn are created. They begin by having items added to their bags (both Godwin and Marilyn get a copy of the Note from Zelda). Then the items they have are used on themselves or one another as follows:
This is a sample of how a Driver could work, staging a battle between the defensive Godwin and the offensive Marilyn.
- The Protection Spell is used on Godwin (by Godwin)
- The Rusty Knife is used on Godwin (by Marilyn)
- The Gladiator's Shield is used on Godwin (by Godwin)
- The Rusty Knife is used on Godwin (by Marilyn)
In: Computer Science
Please read the following restrictions before answering the question below:
Restrictions:
– Do not import any modules other than math and check.
– You are always allowed to define your own helper/wrapper functions. Do not use Python constructs from later modules (e.g. dictionaries, zip, anything with sets or enumerators, list comprehension, commands continue or break).
– Abstract list functions and recursion will not be allowed.
Use only the functions and methods as follows:
∗ abs, len, max, min, sum, range and sorted
∗ Any method or constant in the math module
∗ Type casting including int(), str(), float(), bool(), list()
∗ The command type()
∗ Any basic arithmetic operation (including +, -, *, /, //, %, **)
∗ String or list slicing and indexing as well as string or list operations using the operators above.
∗ Any string or list methods including the in operator.
∗ input and print as well as the formatting parameter end and method format. Note that all prompts must match exactly in order and so ensure that you do not alter these prompts.
∗ Loops, specifically for and while loops.
– Do not mutate any passed parameters unless instructions dictate otherwise. You may mutate lists you have created however.
– While you may use global constants in your solutions, do not use global variables for anything other than testing.
QUESTION:
Write a function
string_clean(s)
which consumes a string s and returns a string. The returned string should be similar to the consumed string, but every time a digit appears in s, a number of characters corresponding to that digit (including the digit itself) should be removed from the returned string. For instance, string_clean("car4pent3ers") => "carts". This should be done left-to-right, and if removing one digit’s substring removes another digit, then that second digit shouldn’t be considered. For instance, string_clean("29Hello!")=> "Hello!". The string must not have any digits that would require removing a substring past the end of the string. This function should run in at worst O(n) time.
Note (and hint!): The join method of strings is O(n), where n is the length of the list, assuming each element of the list is of length O(1).
Samples:
string_clean("") => ""
string_clean("I love CS116!*!*!?") => "I love CS?"
string_clean("6Hello") => ""
string_clean("I have 0 apples and 39 pears") =>
"I have 0 apples and pears"
In: Computer Science
In this assignment, students should create five Java classes called Point, Circle, Square, Rectangle, and TestAll, as well as a Java interface called FigureGeometry. The TestAll class should implement the main method which tests all of the other files created in the assignment. After the assignment has been completed, all six files should be submitted for grading into the Dropbox for Assignment 3, which can be found in the Dropbox menu on the course website. Students should note that only the *.java file for each class /interface needs to be submitted; No *.class files need to be submitted into the Dropbox. Please see below specific requirements for the files that must be created and submitted:
Point.java Description:
The Point class should be declared as a public class and should meet all the requirements listed below. Its purpose is to store the Point (width and height) of a two-dimensional, rectangular geometric figure.
Instance Variables:
private int width;//stores the width of a Point object private
private int height;//stores the height of a Point object
Constructor: Point()
Parameters:
int theWidth,
int theHeight
Purpose: initializes the width and height of a Point object in the following manner:
width = theWidth;
height = theHeight;
Methods:
public int getWidth(){//returns the width of a Point object in the following manner
return width;}
public int getHeight(){//returns the height of a Point object in the following manner:
return height;}
public void setWidth(int theWidth){//assigns the width of a Point object as follows:
width = theWidth;}
public void setHeight(int theHeight{//assigns the height of a Point object as follows:
height = theHeight;
}
FigureGeometry.java Description:
The FigureGeometry interface should be declared as a public interface and should meet all the requirements listed below. Its purpose is to declare all the necessary methods that any geometric figure, such as a circle, rectangle, or square, should contain. The FigureGeometry interface should also declare a numeric constant, called PI, which can be used by classes that implement the FigureGeometry interface. Remember that method declarations in an interface should not include modifiers such as public, static, or abstract.
Declaring a method within an interface as static is illegal and will cause a compilation error. Additionally, the declaration of interface methods using public or abstract modifiers is redundant, and soon such declarations will be deprecated. Students should also note that the inclusion of instance variables within an interface declaration is not allowed; only static constants may be defined within an interface declaration, and the use of the static modifier on constants is also redundant. Basically, students should remember one general rule of thumb concerning interface declarations: Only one modifier should be used in an interface declaration--final should be used to declare constants.
public interface FigureGeometry{final float PI = 3.14f;
//Classes that implement the FigureGeometry interface MUST override this method which should return the geometric area of a figure:
//In an interface, methods are always public and abstract. Using these unnecessary modifiers is redundant, and future versions of
//Java may not support them.
float getArea ();
//Classes that implement the FigureGeometry interface MUST also override this method which should return the geometric perimeter of a //figure:
float getPerimeter ();}
Circle.java Description:
The Circle class should be declared as a public class that implements the FigureGeometry interface described above. Its purpose is to store the radius of a circular figure and provide the methods necessary to calculate the area and perimeter of such a figure.
Instance Variables:
private float radius;//stores the radius of a Circle object
Constructor: Circle()
Parameters:
float theRadius;
Purpose:initializes the radius of a Circle in the following manner:
radius = theRadius;
Methods:
1-public float getRadius(){//returns the radius of a Circle object as follows:
return radius;
}
2-public float getArea(){//returns the area of a Circle object as follows:
return getRadius() * getRadius() * PI;
3-public float getPerimeter(){//returns the perimeter of a Circle object as follows:
return getRadius() * 2 * PI;
}
4-public void setRadius(float theRadius){//assigns the radius of a Circle object as follows:
radius = theRadius;
}
The following coding example illustrates a version of the Circle class:
public class Circle implements FigureGeometry{//Stores the radius of this figure:
private float radius;
//Returns the radius of this figure:
public float getRadius (){return radius;}
//Returns the area of this figure:
public float getArea (){
return getRadius() * getRadius() * PI;}
//Returns the perimeter of this figure:
public float getPerimeter (){ return getRadius() * 2 * PI;}
//Assigns the radius of this figure:
public void setRadius (float theRadius){radius = theRadius;
}
}
Square.java Description:
The Square class should be declared as a public class that
implements the FigureGeometry interface and should meet all the
requirements listed below. Its purpose is to store the Point of a
square figure (using the Point class described above and provide
the methods necessary to calculate the area and perimeter of such a
figure.
Instance Variables:
private Point point; //stores the Point of a Square object
Constructor: Square()
Parameters:
Point p;
Purpose:initializes the object point of the Square object in the following manner:
point= p;
Methods:
1-public float getSideLength(){//returns the length of the side of the square as follows:
return point.getWidth();}
2-public float getArea(){//returns the area of a Square object as follows:
return getSideLength() *getSideLength();}
3-public float getPerimeter(){//returns the perimeter of a Square object as follows:
return getSideLength() * 4;}
4-public void setPoint(Point p){//assigns the point of a Square object as follows:
point= p;}
Rectangle.java Description:
The Rectangle class should be declared as a public class that implements the FigureGeometry interface described above. Its purpose is to store the Point of a rectangular figure (using the Point class described above) and provide the methods necessary to calculate the area and perimeter of such a figure.
Instance Variables:
private Point point;//stores the point of the Rectangle object
Constructor: Rectangle()
Parameters:
Point p;
Purpose: initializes the Point of a Rectangle object in the following manner:
point = p;
Methods:
1-public int getWidth()
{//returns the width of a Rectangle object as follows:
return point.getWidth();}
2-public int getHeight()
{//returns the height of a Rectangle object as follows:
return point.getHeight();}
3-public float getArea()
{//returns the area of a Rectangle object as follows:
return getWidth() * getHeight ();}
4-public float getPerimeter()
{//returns the perimeter of a Rectangle object as follows:
return (getWidth+getHeight()) * 2;}
5-public void setPoint(Point p)
{//assigns the point of a Rectangle object as follows:
point = p;}
TestAll.java Description:
The TestAll class should be declared as a public class and should meet all the requirements listed below. Its purpose is to implement a main method which creates three objects--a Circle object, a Square object, and a Rectangle object-- and test each of the files that have been designed above. You should already be familiar with how to instantiate objects and print values to the screen using System.out.println(...). Therefore, the actual implementation code for this assignment will not be provided. You may organize the output of data according to their own specifications. However, the main method must perform the following tasks:
In: Computer Science
Prob Set 9 E
1. For each of the following countries, find and report the major stock market index values for March 2017 and March 2018 (in this exact order, please do not change): Switzerland (^SSMI), Mexico (^MXX), India (^BSESN), Japan (^N225), France (^FCHI). You can find these data at: http://finance.yahoo.com by entering the symbols above in parentheses for each country in the search box at the top of the page. Click on “Historical Data” and then select “Monthly” for “Frequency” and click on “Apply.” Get the “Adjusted Close” price (local currency) on the right side for March (01) 2017 and March (01) 2018. For the same countries, go to the St. Louis Fed at http://research.stlouisfed.org/fred2/categories/95 and find and report monthly ex-rates for March 2017 and March 2018 for each of the five countries above. Once you select and click on a currency, you can click on “+ more” and then “View All” (upper left corner of screen next to the March 2018 ex-rate) to view the monthly exchange rates. You can also select the “Download” option (upper right corner of screen). Quote ex-rates with both currencies to four decimal places. Note: France uses the Euro as its currency.
a. For each country, report the stock index values and ex-rates for March 2017 and March 2018.
|
Country |
Index |
Value as on 31st march 2017 |
Value as on 31st march 2018 |
Currency |
Value as on 31st march 2017 |
Value as on 31st march 2018 |
|
Switzerland |
(^SSMI) |
8,658.89 |
8,740.97 |
CHF |
1.0031 |
0.9541 |
|
Mexico |
(^MXX) |
48,541.56 |
46,124.85 |
MXN |
18.725 |
18.6 |
|
India |
(^BSESN) |
29,620.50 |
32,968.68 |
INR |
64.86 |
65.115 |
|
Japan |
(^N225) |
18,909.26 |
21,454.30 |
JPY |
111.39 |
106.28 |
|
France |
(^FCHI) |
5,122.51 |
5,167.30 |
EUR |
0.9387 |
0.8115 |
b. Calculate the annual percentage return (%) for each stock market from March 2017 - March 2018, measured in local currency. Use the standard percentage change formula: [(P2 – P1) / P1] x 100), or the %CHG function on your HP calculator and express the answers as a percent to two decimal places, e.g. 3.25%.
c. For each currency, calculate the annual percentage change (to two decimal places, e.g. 3.25%) from March 2017 to March 2018 using the ex-rate exactly as quoted (do not reverse the quote), and for each currency separately, clearly explain in a full sentence or two whether (and why) each of the foreign currencies appreciated or depreciated versus the dollar (use the standard percentage change formula or the %CHG function on your calculator, expressed as a percent).
d. Calculate the effective, annual US dollar return (% to two decimal places) for a U.S. investor who had invested money in the stock markets of each of the five countries during the last year (March 2017 – March 2018), using the formula: Effective Dollar Return (%) = % Foreign Stock Market Return +/- % CHG (Appreciation/Depreciation) in the Foreign Currency
ANswer for B + C + D
| Annual % change for stock market | |
| Country | % Change |
| Switzerland | 0.95% |
| Mexico | -4.98% |
| India | 11.30% |
| Japan | 13.46% |
| France | 0.87% |
| Annual % Change for Currency | |
| Country | |
| Switzerland | -4.88% |
| Mexico | -0.67% |
| India | 0.39% |
| Japan | -4.59% |
| France | -13.55% |
| Dollar Return | ||||||
| Country | Investment | Investment in local currency | Number of Units of index purchased | Value in USD | % USD Return | |
| Switzerland | 1000 | 1003.1 | 0.12 | 1012.61 | 1061.32 | 6.13% |
| Mexico | 1000 | 18725 | 0.39 | 17792.75 | 956.6 | -4.34% |
| India | 1000 | 64860 | 2.19 | 72191.51 | 1108.68 | 10.87% |
| Japan | 1000 | 111390 | 5.89 | 126382.23 | 1189.14 | 18.91% |
| France | 1000 | 938.7 | 0.18 | 946.91 | 1166.86 | 16.69% |
Please assist on question below ( 4 total)
e. Explain your answers from part d for each country, in five separate, short essays of a few sentences per country where you report and explain the effective dollar return for an American investor in each country. Specifically mention both the return on the foreign stock market and the percentage change in the foreign currency over the last year, which together determine the one-year Effective Dollar Return to a U.S. investor.Now do a five-year analysis using the same countries by getting the stock market and ex-rate data for the months March 2013 and March 2018.
In: Finance
Tabitha sells real estate on March 2 for $260,000. The buyer, Ramona, pays the real estate taxes of $5,200 for the calendar year, which is the real estate property tax year. Assume that this is not a leap year.
a. Determine the real estate taxes apportioned to and deductible by the seller, Tabitha, and the amount of taxes deductible by Ramona.
b. Calculate Ramona’s basis in the property and the amount realized by Tabitha from the sale.
In: Accounting
Tom sells real estate on March 2 for $260,000. The buyer, Raul, pays the real estate taxes of $5,200 for the calendar year, which is the real estate property tax year. Assume that this is not a leap year.
A. Determine the real estate taxes apportioned to and deductible by the seller, Tom, and the amount of taxes deductible by Raul.
B. Calculate Raul's basis in the property and the amount realized by Tom from the sale.
In: Accounting
If a sum of $9257 is deposited now, $1374 two years from now, and $1375 per year in years 6 through 10, the amount in year 10 at an interest rate of 10% per year will be closest to:
a. $35350
b. $35346
c. $100368
d. None of the answers
In: Finance
The price of a stock is $55 at the beginning of the year and $50 at the end of the year. If the stock paid a $3 dividend and inflation was 3%, what is the real holding-period return for the year?
In: Finance
what is the 3 year financial forecasting for Nvidia?
In: Finance
Year
Technology Energy
2000: -24.31 30.47
2001: -38.55 -12.49
2002: -36.89 -11.61
2003: 68.59 27.84
2004: -9.98 35.94
2005: 17.81 70.70
2006: 3.79 -2.12
2007: -3.13 29.30
2008: -42.51 -48.25
2009: 79.03 40.13
2010: 45.03 34.25
2011: -12.21 -8.76
what I have to find. There are 2 data FUNDS in the file: Technology and Energy.
1) For each fund, compute using Excel: the Average, Median, Mode, the first percentile, the third percentile.
2) Graph the Box-Plot for each fund (called Box and Whisker in Excel).
3) For each fund, compute using Excel: the Range, Mean Absolute Deviation, the variance, the standard deviation and the coefficient of variation.
4) Using Excel, compute the Sharpe-Ratio for each fund using the risk free return of 3%. 5) Using Excel, compute the correlation between both funds.
In: Statistics and Probability