![]() ![]() |
Home |
How it works |
Projects archive |
Contact Us Air Compressor Bot |
|
| The Career Path of Freelance Programming Jobs |
Java Programming |
![]() |
Bidding Time: |
03/04/2005 23:24 - 06/04/2005 23:24 |
Budget: |
$0-150 |
Status: |
Closed |
|
|
|
Job Type: |
|
Description: |
programming language. These won't take long and you will make a quick buck. \ You can retrieve the projects from http://www.zeta-x.com/Assignments.zip http://www.zeta-x.com/Files.zip Thanks! Additional Info (Added 4/3/2005 at 23:29 EST)... Assignment #1 # Go to the zipped folder 1. # Create an interface, Pokeable. It should contain a single method header for the method endurePoke(). Recall that the method header for this method in the Monster class is: public void endurePoke(double poke) # Modify the Monster class so that it implements the interface Pokeable. # Create two new classes, WimpyMonster and ArmoredMonster. Both classes should be the same as the Monster class, except for parts of the endurePoke() method. The endurePoke() method in WimpyMonster should cause its monster's strength to be set to 0, while the endurePoke() method in ArmoredMonster should only reduce the strength of its monster by 10% of the value of the poke. The rest of the method can be the same. # Create an interface, EndureStrategy. It should contain two method headers: affectHealth (takes in a double parameter containing the value of a pokeForce, a double parameter containing the current value of health, and returns a double containing the new value of health) and affectStrength (takes in a double parameter containing the value of a pokeForce, a double parameter containing the current value of strength, and returns a double containing the new value of strength). # Add an instance variable strategy of type EndureStrategy to your Monster class. # Add a parameter of type EndureStrategy to your Monster class constructor, and use it to set your strategy instance variable. # In the body of your endurePoke method, update health and strength by invoking both EndureStrategy methods using your strategy instance variable. # Now write three inner classes that implement EndureStrategy within your tester: TimidStrategy, RegularStrategy, and ArmoredStrategy (that is all that they have to do: they won't have any extra variables or methods). Each of these classes will provide bodies for the EndureStrategy methods based on the different algorithms described in Part 1. # Now create objects of each of the above classes, and instantiate them to a variable of type EndureStrategy. # Finally, create an adventurer and a monster. This time when you create the monster, be sure to send one of the EndureStrategy variables as an argument to the constructor. Test as before. # Do the same, this time with one of the other EndureStrategy variables, and then one more time with the last EndureStrategy variables. # Your monster should appear to behave somewhat differently (within the bounds of its randomly generated health and strength) according to the strategy it employs. You might want to use the set methods in Adventurer to force its health and strength to be the same for each test, as well as the set methods in each monster type to set each one's health and strength to be the same also. # Add a set Strategy method that takes in a variable of type EndureStrategy so that you can alter the Monster's strategy at will. With a strategy interface, you are not limited to a particular strategy for the life of the object, but can change it. Additional Info (Added 4/3/2005 at 23:30 EST)... Assignment 2 * Start with your project from Assignment 1. * Create a GameCharacter class. It should contain all the constants, instants variables, and instance methods (including bodies) that are common to the Adventurer and Monster classes (feel free to cut and paste). o It should have two constructors (similar to those of Adventurer and Monster): The first should take in as its parameters a String (for a name) and an instance of Random, and should set number of sacks to a random number between 1 and 10. The second should take in as its parameters a String (for a name), an instance of Random, and an int (for number of sacks). Otherwise, they should initialize their instance variables in the same way as Adventurer and Monster. * Make Adventurer a subclass of GameCharacter. It will have its own constructor, pokeEvilMonster and endureRoar methods, and will override the GameCharacter toString method. Apart from that, it will inherit the instance variables and methods from GameCharacter. o The constructor of a subclass should invoke the superclass constructor first (super( )), passing any arguments as necessary (Remember that the Adventurer's sacks are initialized to zero). o Because a subclass cannot access the private data members of its superclass, remember to use accessor and mutator methods when examining or setting instance variables of the superclass (super.get_____( ) methods and super.set_____( ) methods). o One way to override a superclass method is to provide some unique code as well as invoke the superclass version of the method. Do this with toString. * Make Monster a subclass of GameCharacter. It will have an instance variable strategy of type EndureStrategy, its own constructor, its own frightenBraveAdventurer and endurePoke methods, and will override the GameCharacter toString method. Apart from that, it will inherit the instance variables and methods from GameCharacter. o This constructor will take in a String (for a name), and instance of Random, and an instance of EndureStrategy. It will also invoke the superclass constructor first (Remember that the Monster's sacks are initialized to a random number). It will also use its EndureStrategy parameter to set the value of its strategy instance variable. o Modify the remaining methods as per Adventurer. * Now re-run the previous tests (with the different types of monsters). Additional Info (Added 4/3/2005 at 23:32 EST)... Assignment 3 * Create a new project using the MainFrame and PanelCreator * Zork Characters: o Copy the following classes and interface from your InLab 8 Zork program to your new project: GameCharacter, Adventurer, Monster, and EndureStrategy. Take a look at the code in your tester. You will be writing an inner class for this new project like the one you wrote for InLab 8 that incorporated the regular strategy (more about this later). o Modify the loseTreasure method in GameCharacter so that when a character loses all sacks, both strength AND health is regained * MainFrame: o This code is almost all "boiler plate code" that can be used exactly as is. The only changes you will make in MainFrame are: + the name of the class (if desired) + the comments (update as needed) + the title for the frame + remove the model that is instantiated and passed to the PanelCreator (Create the models inside PanelCreator instead) * PanelCreator: o There will be significant changes to PanelCreator, but the overall pattern will be the same. In particular, the control panel is quite a bit more complicated. It will contain three buttons (or some other type of widgets): create monster, create adventurer, and poke monster. The view panel is slightly more complicated. You will be required to make it using two subpanels (which are instances of the new SubPanelCreator class, discussed below): one to view the state of the monster, and one to view the state of the adventurer. o Here are some hints: + Instead of having the models (adventurer, monster) passed in, declare and and create them in PanelCreator. Don't forget that in order to do this, PanelCreator will need to create an instance of Random also. + Don't forget to write a class that implements EndureStrategy which incorporates the regular strategy from InLab 8. You will need an instance of this class in order to create your monster. + You have already seen that is perfectly legal for a method to contain one or more inner classes. It is also legal for a method in an inner class to contain one or more inner classes . . . + You can disable a button with the following: buttonVariableName.setEnabled(false) + You can enable a button with the following: buttonVariableName.setEnabled(true) + In class, we saw how to add a JButton to a JPanel. You can also add a JPanel to a JPanel (or two or three or more) + The default layout manager for a JPanel is FlowLayout. However, you can set your own layout manager using the setLayout() method + Whenever you click on the create monster button, a new monster should be created whose state should be displayed + Whenever you click on the create adventurer button, a new adventurer should be created whose state should be displayed + The poke monster button should not be enabled if there is no monster or if there is no adventurer + When the monster's strength has been reduced to zero, he/she should lose a sack, the adventurer should gain a sack, the monster should regain strength, the adventurer should lose some strength (this is the way it worked the last time you worked on this) + The monster's sacks should never go below zero + When all of the monster's sacks have been stolen by the adventurer, the monster should regain strength AND health (note modification to GameCharacter above), and the adventurer's pokes shouldn't have any more effect (this is new) o Your PanelCreator class must use the same organization as the example covered in class. The design and/or layout of the controller panel(s) and viewer panel(s) is where you will make choices and show your creativity. * SubPanelCreator: o You will create a new class called SubPanelCreator. o It will have two instance variables: an instance of the class GameCharacter (the model), and an instance of the class JLabel (used for viewing the model) o The constructor for SubPanelCreator will take in no parameters, set character to null, and set the JLabel to "No character defined" o The SubPanelCreator class will contain the following methods: + hasCharacter: returns a boolean, false if character is null, true otherwise + updateView: sets the JLabel text equal to the value returned by the method toString on the character + setCharacter: takes in a GameCharacter as a parameter, uses it to set the instance of GameCharacter instance variable, and calls updateView + getViewPanel: returns a panel to which the JLabel has been added STOPzilla! Anti-Spyware Software
This project is the proprietary information of .
Click here to remove this project from OUR database.
|
Operating System: |
Windows |
Database System: |
(None) |
| <<< back |
|
| Home | Projects archive | RSS | Resources | Links | Contact Us | © 2004-2009 ProjectsList.biz /0.039 |