Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

P05 Dragon Treasure Adventure 2.0 Programming II (CS300) Fall 2022 Pair Programming: ALLOWED Due: 9:59PM on October 26th P05 Dragon Treasure Adventure 2.0 Overview In P03, you each implemented...

1 answer below »
P05 Dragon Treasure Adventure 2.0
Programming II (CS300) Fall 2022
Pair Programming: ALLOWED
Due: 9:59PM on October 26th
P05 Dragon Treasure Adventure 2.0
Overview
In P03, you each implemented instantiable classes to make a simple text-based adventure game.
If you recall, you wrote a lot of similar code (e.g. Dragon and Player) in multiple places or had
a large set of methods or fields that were used for only one type of Room (e.g. teleportLocation
or getPortalWarning()). Using the OOP concepts of inheritance, interfaces, and encapsulation,
we will iterate on the previous version of Dragon Treasure Adventure by restructuring the code
and incorporating some rudimentary graphics using the same GUI and processing li
ary as in
P02! You can view a demo of the finished project here.
Grading Ru
ic
5 points Pre-Assignment Quiz: The P5 pre-assignment quiz is accessible through
Canvas before having access to this specification by 11:59PM on Sunday
10/23/2022. You CANNOT take the pre-assignment quiz for credit passing
its deadline. But you can still access it. The pre-assignment quiz contains
hints which can help you in the development of this assignment.
20 points Immediate Automated Tests: Upon submission of your assignment
to Gradescope, you will receive feedback from automated grading tests
about whether specific parts of your submission conform to this write-up
specification. If these tests detect problems in your code, they will attempt to
give you some feedback about the kind of defect that they noticed. Note that
passing all of these tests does NOT mean your program is otherwise co
ect.
To become more confident of this, you should run additional tests of your own.
15 points Additional Automated Tests: When your manual grading feedback
appears on Gradescope, you will also see the feedback from these additional
automated grading tests. These tests are similar to the Immediate Automated
Tests, but may test different parts of your submission in different ways.
10 points Manual Grading Feedback: After the deadline for an assignment has
passed, the course staff will begin manually grading your submission. We
will focus on looking at your algorithms, use of programming constructs, and
the style and readability of your code. This grading usually takes about a week
from the hard deadline, after which you will find feedback on Gradescope.
©2022 Kacem, LeGault, Jensen, & Nyhoff - University of Wisconsin - Madison.
https:
mediaspace.wisc.edu/media/P05%20Dragon%20Treasure%20Adventure%202.0%20Demo/1_q7bvflu
https:
www.gradescope.com
https:
www.gradescope.com
https:
www.gradescope.com
Learning Objectives
The goals of this assignment include:
• Implementing an interface.
• Practice with coding and utilizing inheritance in a program.
• Practice ove
iding methods from a parent class or interface.
• More practice with instantiable classes and throwing exceptions.
• Seeing polymorphism being used in action!
Additional Assignment Requirements and Notes
(Please read carefully!)
• Pair programming is ALLOWED but not required for this assignment. If you decide
to work with a partner on this assignment, REGISTER your partnership NO LATER
than 11:59PM on Sunday 10/23/2022 and MAKE SURE that you have read and
understood the CS300 Pair Programming Policy.
• The ONLY external li
aries you may use in your program are these li
aries:
java.io.File, java.io.IOException, java.util.A
ayList, java.util.Scanner,
java.util.Random, processing.core.PApplet, and processing.core.PImage.
• Only your submitted DragonTreasureGame class can contain a main method.
• You are NOT allowed to add any constant or variable not defined in this write-up outside
of any method.
• You CAN define local variables (inside a method) or private helper methods that you
may need to implement the methods defined in this program.
• You CAN NOT add any public methods to your classes other than those defined in
this write-up.
• Feel free to reuse any of the provided source code or javadoc comments in this write-up
ve
atim in your own submission.
• Be sure that your code follows the CS300 Course Style Guide.
• You MUST adhere to the Academic Conduct Expectations and Advice.
• Make sure that all ove
idden methods contain a @Ove
ide above the method signature.
2
http:
tiny.cc/partnershipRegistration
https:
canvas.wisc.edu/courses/323005/pages/pair-programming-policy
https:
canvas.wisc.edu/courses/323005/pages/course-style-guide
https:
canvas.wisc.edu/courses/323005/pages/assignment-expectations-and-advice
1 Getting Started
• Start by creating a new Java Project in eclipse calledP05 Dragon Treasure Adventure
2.0, or something similar. As always make sure that you are using Java 17, don’t add a
module, and that you use the default package.
• Then, create a new Java class called DragonTreasureGame and add a main() method.
• Download this core.jar file so that you have the processing li
ary needed for the GUI. Add
it to your project folder, right-click it, and pick “Build Path > Add to Build Path”. (You
may need to refresh the Project Explorer in Eclipse if the jar doesn’t appear immediately.)
• Finally, download this zip file that holds all the images and add them to a folder called
“images” in your project.
• Here you can download a completed implementation of P03 that you can use as a reference
to help with implementing this program.
2 Game Overview & Changes
In this game the player will be placed into a room in the cave based on a layout that has been
loaded in. The player gives input about which room they’d like to move to and will move to
that room (if allowed). The game will print out messages if certain dangers or special rooms
are nea
y. The dragon also gets to make a move and enter a new room. This behavior will
epeat until either 1) the player reaches the treasure room unharmed or 2) the dragon catches
up to the player and burns them to a crisp.
NEW to 2.0!
• Instead of using solely text to interact with the player, graphics will be used to show some
visuals of the room and the keyboard directly to receive input.
• Portal rooms will now teleport the player to any random room that is adjacent to it.
• One more gameplay addition will be a “KEYHOLDER” character who is stationary.
• The player must find and visit them before being able to open the treasure chest and win.
3 Setting Up the GUI
First let’s start by getting our game window up and running! In P02, we relied on the Utility
class to do a lot of the work for us. This time around we will use the PApplet class by using
inheritance.
3
https:
canvas.wisc.edu/courses/323005/files/ XXXXXXXXXX/download?download_frd=1
https:
canvas.wisc.edu/courses/323005/files/ XXXXXXXXXX/download?download_frd=1
https:
canvas.wisc.edu/courses/323005/files/ XXXXXXXXXX/download?download_frd=1
• Now, make the DragonTreasureGame class inherit from PApplet. Make sure to import
processing.core.PApplet to make your code compiles.
• Inside the main() method, call PApplet.main("DragonTreasureGame").
• If you launch your program successfully, right now a very small window should appear.
Let’s continue to make some adjustment to it.
• Add and ove
ide the public void settings() method.
• In the settings() method add a call to size(800,600). This will set the window to
have a width of 800 and height of 600.
• Next, add and ove
ide the public void setup() method. Add the following code to
the beginning of the method:
this.getSurface().setTitle("Dragon Treasure Adventure");
sets the title of the window
this.imageMode(PApplet.CORNER);
Images are drawn using the x,y-coordinate
as the top-left corne
this.rectMode(PApplet.CORNERS);
When drawing rectangles interprets args
as top-left corner and bottom-right corner respectively
this.focused = true;
window will be active upon running program
this.textAlign(CENTER);
sets the text alignment to cente
this.textSize(20);
sets the font size for the text
• [CHECKPOINT] Once you’ve completed these steps, you should see a blank window
as pictured below with no e
ors upon running the program!
4
4 Building Rooms
Instead of shoving all different types of room information into one class, we’ll restructure it
into one parent (base) class Room and the remainder into children (derived) classes.
• Start by creating a new Java class in your project named Room.java. Then add the
following data fields:
private String description;
ve
al description of the room
private A
ayList adjRooms;
list of all rooms directly connect
private final int ID;
a "unique" identifier for each room
protected static PApplet processing;
PApplet object which the rooms will use to
draw stuff to the GUI
private PImage image;
stores the image that co
esponds to the background of a room
Now go ahead and implement the methods for the Room class as described in the Javadocs.
A lot of them should be familia
similar to the ones found in P03. We’ll also provide a bit of
extra information on the two completely
and new methods.
• Take note of the setProcessing() method. If this is not implemented co
ectly, then
the program will have issues drawing things to the window.
• The draw() method will need to do the following steps:
1. Use the PApplet’s image() instance method to draw the image at (0, 0).
2. Use the PApplet’s fill() instance method to change the draw color to giving it a value
of −7028. This will change it to Flavescent a light yellow-
own color.
3. Use the PApplet’s rect() instance method to draw a rectangle. The first two arguments
are the xy-coordinates of the top left corner respectively. The third and fourth
arguments are the xy-coordinates of the bottom right corner respectively. Place the
upper left corner at (0, 500) and the other at (800, 600).
4. Use the PApplet’s fill() instance method again to change the draw color to giving it
a value of 0. This will change it to black.
5. Use the PApplet’s text() instance method to draw the Room’s toString() at (300, 525).
• Once you’re done implementing them, return back to your DragonTreasureGame class
and add this data field: private A
ayList roomList. In the setup()method
initialize it to an empty A
ayList.
• In setup() call Room.setProcessing(). Remember that setProcessing() takes a
PApplet as its argument, and that DragonTreasureGame is a PApplet.
5
https:
cs300-www.cs.wisc.edu/wp/wp-content/uploads/2020/12/fall2022/p5/javadocs/Room.html
https:
processing.org
eference/image_.html
https:
processing.org
eference/fill_.html
https:
processing.org
eference
ect_.html
https:
processing.org
eference/fill_.html
https:
processing.org
eference/text_.html
• [CHECKPOINT] In setup() use PApplet’s loadImage() instance method to load an
image from the “images” folder. Use that PImage to make a new Room object and add it
to the A
ayList.
• Add a new method public void draw() in DragonTreasureGame. In this method call
the Room’s draw() method. If you run your program you should see the image, rectangle,
and text of the room in the window. If you use 1.jpg as the image, that will look like:
4.1 StartRoom Child Class
We’ll start out with one of the simpler children classes first.
• In your project create a new class called StartRoom. This class should inherit from the
Room class you wrote earlier.
• Add to this class a constructor with the following signature:
public StartRoom(int ID, PImage image){};
• Now go ahead and implement the constructor such that a StartRoom by calling the
super() constructor will have the following description reading.
"You find yourself in the entrance to a cave holding treasure."
6
https:
processing.org
eference/loadImage_.html
• [CHECKPOINT] Return to
Answered Same Day Oct 29, 2022

Solution

Aditi answered on Oct 29 2022
59 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here