Question

HELP....ITS CLOSING TONIGHT INFSCI 0017 – Assignment 4 You are doing an internship in a company...

HELP....ITS CLOSING TONIGHT

INFSCI 0017 – Assignment 4 You are doing an internship in a company specialized in create role-­‐playing computer games. As a part of the programming team, you are asked to implement and test the first version of a RolePlayer class. In the game, a RolePlayer is a knight with the mission of fight and kill monsters: vampires and werewolves. As the player defeat monsters, he/she gains points. The player is considered trainee if he/she has less than 1000 points, a "beginner" with more than 1000 points and less than 3000, and a "master" when he/she reaches 3000 points. Each time the player wants to fight a monster, he/she toss a dice one or more times, depending on the level. A trainee toss the dice twice. A beginner toss the dice 3 times, and a master toss the dice 4 times. To defeat a vampire, the player needs at least 11 points. To defeat a warewolf, the player needs at least 7 points. A defeated vampire makes 300 points. A defeated werewolf makes 150 points.

1. Create a Eclipse project named [your pitt id]_assignment4

2. Create a package edu.pitt.is17.[your pitt id].assignment4

3. Add the class Dice to your package. It represent a cube dice (6 possible values.) This class is already implemented and you have to use it as is (do not modify it!!)

public class Dice {

int sides;

public Dice(){

sides = 6;

}

public int roll(){

return (int) (sides*Math.random() + 1);

}

} 4. Implement the class Monster following the class diagram. Add a constructor which receives a string contaning "vampire" or "werewolf" and sets the attribute specie. Make the constructor validate that the specie is "vampire" or "werewolf" (regardless case -­‐uppercase or lowercase) and set it as a "werewolf" as a default value if specie parameter is not valid. Add a getter for attribute specie, but do not add a setter method.

                                            Monster
- specie : String

5. Implement the class RolePlayer as defined by the design team of the company in the following diagram. Methods are described in the side.

                                                   RolePlayer

-name : string

-score : int

-dice: Dice

+ fight (monster: Monster) : boolean

+level() : String

+getscore() : int

fight: depending on the score of the player, it rolls the dice 2, 3 or 4 times. Depending on the sum of the dice tosses and the opponent specie ("vampire" or "werewolf") the fight is won or lost. See the rules described in the first paragraph. Make sure it can recognize "vampire" or "werewolf" no mater if lowercase or uppercase. If the figth is won, points are added to the attribute score of the player (makes 300 points per vampire and 150 points per werewolf.) The method returns true if the fight is won, and false if not. §

level: returns "trainee", "beginner" or "master" depending on the value of the attribute score. See rules described in the first paragraph.

 getScore: returns the attribute score value.

 Add a constructor receiving the name. Also, in the constructor initialize score in 0 and create the dice.

 Add a getter method for name attribute.

6. You know that good practices of programming are quite important, so consider to define and use constants while implementing the RolePlayer class. For example, 1000 points defines the lower bound for being a "beginner". Thus, a constant can be defined to be used:

private final int BEGINNER_LOWER_BOUND = 1000;

Folow a similar approach for all literal values you use in your program.

7. Test your RolePlayer class with the following program. Make sure the methods in the class RolePlayer work well.

public class RoleGameTest {

public static void main(String[] args) {

RolePlayer player = new RolePlayer("John Snow");

battle(player,new Monster("vampire"));

battle(player, new Monster("werewolf"));

battle(player, new Monster("werewolf"));

battle(player, new Monster("werewolf"));

battle(player, new Monster("vampire"));

battle(player, new Monster("werewolf"));

battle(player, new Monster("vampire"));

battle(player, new Monster("vampire"));

battle(player, new Monster("vampire"));

battle(player, new Monster("werewolf")); }

public static void battle(RolePlayer p, Monster opponent){

if (p.fight(opponent)) {

System.out.println(p.getName() + " fought a " + opponent.getSpecie()+" and win (level: " + p.level() + ", score: "+p.getScore() + ")");

}else{ System.out.println(p.getName() + " fought a " + opponent.getSpecie()+" and lost (level: " + p.level()+ ", score: "+p.getScore() + ")");

}

}

}

General aspects: ● Write meaningful comments for every variable and every step in your solutions – make sure to explain what each variables represents. The goal is to make you explicitly reflect about every step in your program. ● Follow the name conventions for naming your classes, variables and constants. ● Make sure your indentation is correct. You can use Correct Indentation menu option in Eclipse before submitting your code. Export your project and compress it in a file named [your pitt id]_assignment4.zip. Due date is Monday Feb 29th 23:59 PM. Submit using courseweb submission tool.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
HELP....ITS CLOSING TONIGHT INFSCI 0017 – Assignment 4 You are doing an internship in a company...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Hello, Could you please help me code this program in Java? It is important that all...

    Hello, Could you please help me code this program in Java? It is important that all rules are carefully followed. Using the PairOfDice class from PP 4.9, design and implement a class to play a game called Pig. In this game, the user competes against the computer. On each turn, the current player rolls a pair of dice and accumulates points. The goal is to reach 100 points before your opponent does. If, on any turn, the player rolls a...

  • I am having an issue adding in the following strenght and defense criteria. *Mob, *charm, *Hogwarts....

    I am having an issue adding in the following strenght and defense criteria. *Mob, *charm, *Hogwarts. Can you help please? Requirements In this project, you will create a simple class hierarchy as the basis for a fantasy combat game. Your ‘universe’ contains Vampires, Barbarians, Blue Men, Medusa and Harry Potter. Each has characteristics for attack, defense, armor, and strength points as follows. Type Attack Defense Armor Strength Points Vampire1 1d12 1d6* Charm 1 18 Barbarian2    2d6 2d6 0 12 Blue...

  • Read through the code of the class Player, noting it has two instance variables, name and rank, which are of type String and three further instance variables won, drew and lost which are of type int....

    Read through the code of the class Player, noting it has two instance variables, name and rank, which are of type String and three further instance variables won, drew and lost which are of type int. There is also an attribute of the class, points, which does not have a corresponding instance variable. Also note the constructor and methods of the class and what they do. TournamentAdmin class code: public class RankAdmin {    /**     * Constructor for objects of class...

  • 1 Overview For this assignment you are required to write a Java program that plays (n,...

    1 Overview For this assignment you are required to write a Java program that plays (n, k)-tic-tac-toe; (n, k)-tic- tac-toe is played on a board of size n x n and to win the game a player needs to put k symbols on adjacent positions of the same row, column, or diagonal. The program will play against a human opponent. You will be given code for displaying the gameboard on the screen. 2 The Algorithm for Playing (n, k)-Tic-Tac-Toe The...

  • First, you will need to create the Creature class. Creatures have 2 member variables: a name,...

    First, you will need to create the Creature class. Creatures have 2 member variables: a name, and the number of gold coins that they are carrying. Write a constructor, getter functions for each member, and 2 other functions: - void addGoldCoins(int) adds gold coins to the Creature. - void identify() prints the Creature information. The following should run in main: Creature d{"dragon", 50}; d.addGoldCoins(10); d.identify(); // This prints: The dragon is carrying 60 gold coins. Second, you are going to...

  • This java assignment will give you practice with classes, methods, and arrays. Part 1: Player Class...

    This java assignment will give you practice with classes, methods, and arrays. Part 1: Player Class Write a class named Player that stores a player’s name and the player’s high score. A player is described by:  player’s name  player’s high score In your class, include:  instance data variables  two constructors  getters and setters  include appropriate value checks when applicable  a toString method Part 2: PlayersList Class Write a class that manages a list...

  • This is my code for my game called Reversi, I need to you to make the...

    This is my code for my game called Reversi, I need to you to make the Tester program that will run and complete the game. Below is my code, please add comments and Javadoc. Thank you. public class Cell { // Displays 'B' for the black disk player. public static final char BLACK = 'B'; // Displays 'W' for the white disk player. public static final char WHITE = 'W'; // Displays '*' for the possible moves available. public static...

  • In C++ program Fishing Game Simulation   For this assignment, you will write a program that simulates a fishing game. In this game, a six-sided die is rolled to determine what the user has caught. Eac...

    In C++ program Fishing Game Simulation   For this assignment, you will write a program that simulates a fishing game. In this game, a six-sided die is rolled to determine what the user has caught. Each possible item is worth a certain number of fishing points. The points will not be displayed until the user has finished fishing, and then a message is displayed congratulating the user depending on the number of fishing points gained.   Here are some suggestions for the...

  • Java BlackJack Game: Help with 1-4 using the provided code below Source code for Project3.java: import...

    Java BlackJack Game: Help with 1-4 using the provided code below Source code for Project3.java: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class Project3 extends JFrame implements ActionListener { private static int winxpos = 0, winypos = 0; // place window here private JButton exitButton, hitButton, stayButton, dealButton, newGameButton; private CardList theDeck = null; private JPanel northPanel; private MyPanel centerPanel; private static JFrame myFrame = null; private CardList playerHand = new CardList(0); private CardList dealerHand = new CardList(0);...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT