Our Services

Get 15% Discount on your First Order

[rank_math_breadcrumb]

HW 4 COS

PLEASE REVIEW THE INFO BELOW 

Upload the .java source code file AND DON’T ZIP FILES AS I HAVE SEEN MANY STUDENT DID IT IN THEIR PREVIOUS ASSIGNMENT.

In a single file named game.java, create an Enemy class, Player class, and gameObject class.  The Enemy and Player (sub) classes should inherit from the gameObject (super) class.  Create a player and a few enemies.  Create the basic movements (left/right/up/down) for the player.  Develop a menu in the main method that allows the player to move around.

gameObject SuperClass

Variables

Description

static char World[][] = new char[41][21];

This is the character array that will store what is at each X,Y location.  It is static so there is only one World for all game objects.

int Xpos, Ypos

X,Y location of the game object.  The top left of the screen will be 1,1.

int HP

Hitpoints of the game object – it is alive as long as HP > 0

int Attack

Attack rating of the game object – the higher the number, the more damage it does

int Armor (optional)

Armor rating of the game object – the higher the number, the less damage it takes when attacked

char Avatar

The character that will be displayed when the World is printed

Methods

Description

PrintWorld()

This will print the World to the screen.  Example code:
for (int y=1; y<=20; y++)
{
   for (int x=1; x<=40; x++)
   {
      System.out.print(World[x][y]);
      // optionally put a space after each element
      if (x < 40) System.out.print(” “);
   }
   System.out.println();
}

MoveRight()

Move the game object to the right.  Here’s some example code:
if (World[Xpos+1][Ypos] == ‘ ‘)
{
   World[Xpos][Ypos] = ‘ ‘;
   Xpos++;
   World[Xpos][Ypos] = Avatar;
}

MoveLeft()

Move the game object to the left.

MoveUp()

Move the game object to the up.

MoveDown()

Move the gameobject to the down.

Enemy SubClass (inherits from gameObject)

Variable Names

Variable Description

String Type

Type of enemy such as “Orc” or “Troll”

int Speed (optional)

The speed of the enemy.  You could have some enemies move 2 spaces per turn instead of 1.

Methods Names

Methods Description

Enemy()

Constructor that takes 1 parameter – Type

You can set the Enemy’s Xpos,Ypos to a random location

In the constructor, you will set these things based on the Race:  HP, Attack, Armor, Speed, Avatar.  For example:
if (Type.equals(“Orc”))
{  HP = 50;  Attack = 5;  Armor = 20;  Speed = 1;  Avatar = ‘O’; }

Player SubClass (inherits from gameObject)

Variable Names

Variable Description

String Name

Name of the player.

int Gold (optional)

The amount of gold the player has collected.

Methods Names

Methods Description

Player()

Constructor that takes 2 parameters – Name, Avatar

Since there will only be 1 player, this constructor will only be called once.  Therefore you can initialize the World here.  Here’s some example things you could do:

// set entire world to spaces
for (int x=1; x<=40; x++)
   for (int y=1; y<=20; y++)
      World[x][y] = ‘ ‘;

// put the player into the world after filling it with spaces
XPos=2;  YPos=2;  World[2][2]=Avatar;

// line perimeter of world with trees ‘@’
for (int x=1; x<=40; x++)
{  World[x][1] = ‘@’;  World[x][20] = ‘@’;  }
for (int y=1; y<=20; y++)
{  World[1][y] = ‘@’;  World[40][y] = ‘@’;  }

// draw a lake at a random location ~
int a = (int)(Math.random()*30)+4;
int b = (int)(Math.random()*10)+3;
World[a][b] = ‘~’; World[a+1][b] = ‘~’; World[a+2][b] = ‘~’;
World[a][b+1] = ‘~’; World[a+1][b+1] = ‘~’; World[a+2][b+1] = ‘~’;
World[a][b+2] = ‘~’; World[a+1][b+2] = ‘~’; World[a+2][b+2] = ‘~’;

 

Below is an example screen print showing the player, Orcs, Trolls, armor and weapons.

@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
@ K             $                                                           @
@                                                                           @
@         %                                                     O     O     @
@                                                                     O     @
@                     ~ ~ ~                               T                 @
@                     ~ ~ ~             O O                                 @
@                     ~ ~ ~             O O                                 @
@           +                                                               @
@                                                                           @
@                         $                                                 @
@                                                                           @
@                                                                           @
@                                                                     +     @
@       O O                         %                                       @
@                                                                           @
@               $                                                           @
@                                       $                     T             @
@                                                                           @
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @

Enter your command:

 

The main program will be rather simple since many things are handled in the classes.

import java.util.*;
public class game
{
   public static void main (String[] args)
   {
      Scanner in = new Scanner(System.in);
      String Choice = “”;

      // creating the player will initialize the world
      Player P = new Player(“Kirk”,’K’);

      // create some enemies in random locations
      Enemy E1 = new Enemy(“Dragon”);
      
      while (!Choice.equals(“q”))
      {
         P.PrintWorld();
         System.out.println(“Enter your command: “);
         Choice = in.nextLine();

         // call move methods – you can use the standard gaming directions – a,s,d,w
         if (Choice.equals(“a”))
            P.MoveLeft();
      }
   }
}

BELOW IS THE PICTURE IF YOU DONT UNDERSTAND THE INFORMATION ABOVE

image1.png

image2.png

image3.png

image4.png

image5.png

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

Wk4_300

Need help with a question. Due 3/10/2025 @ 9PM n the Week 4 labs, you performed tasks such as creating a cluster, restoring files, configuring account lockout policies, and verifying RAM usage.  Note: Ensure you have completed all lab exercises from Week 4 before completing this assessment. Assessment Details Write a 350-

Event Khusus dan Promosi di Witching Pot

“Saya sangat puas dengan pengalaman taruhan di situs ini. Setiap elemen, dari navigasi hingga pembayaran, berjalan dengan mulus. Ini menunjukkan profesionalisme dan kualitas layanan mereka. Saya pasti akan kembali lagi!”

Business/computer

Isolation Discussion Thread: Cybersecurity — Layering-Abstraction-Process Isolation The NSA has identified what they call the First Principles of cybersecurity. The following lists three of these: Principle Last Name Starts With Layering A through H Abstraction I through Q Process Isolation R through Z For your discussion, describe the principle assigned

D 3 of 459

 Building Block Technologies    What is an operational technology?  How is it similar or different than Consumer IoT? What emerging risks can you identify for an operational technology in a hypothetical utilities distribution monitoring & control environment (pipelines & transmission grids)?

D 2 of 459

  Follow the attach document to complete this work. Questions: 1. Consumer Internet of Things (IoT) has become ubiquitous and represents a major vector of cyber risk. Provide examples of consumer IoT that may be found in your own home (not sharing exact details is OK) 2. Provide a high

D 1 of 459

Follow the attach document to complete this work. Building Block Technologies   1. Software, Hardware, and Network Communications are considered building block technologies for enterprises. Define what they are, how they are used and give an example. 2. What are the most notable cyber risks for each type of building block?

D 8 0f 360

Follow the attach document to complete this work. International Cooperation for Cybersecurity   Prepare a 5- to 7-paragraph briefing statement that explains why wealthy nations and developing nations should work together to improve cybersecurity for the globally connected networks referred to as “the Internet.” Your statement should address the following.

D 7 of 360

Follow the attach document to complete this work. Policy Soup: Dealing with the Aftermath of a New Cybersecurity Policy   Prepare a 5 to 7 paragraph “Expert Opinion” for local government officials. This document should present a strategy for communicating with residents about a new “cybersecurity” policy that requires a

D 6 of 360

Follow the attach document to complete this work.  Partnerships for Improving State and Local Government Cybersecurity   Before you begin, read this report:  National League of Cities ( ) (Click the Download Report link at the bottom of the page) Prepare a briefing statement (3 to 5 paragraphs) for a group

D 5 of 360

Follow the attach instruction to complete this work. Background Briefing: How will the Governor’s Initiatives Improve Cybersecurity for the State’s Critical Infrastructures?   Discussion we transition from federal to state critical infrastructure. You are working for the Chief of Staff (CoS) for a newly elected Governor. The governor asked the

D 4 of 360

Follow the attach instruction to complete this work. Panel Presentation: Privacy Impact Assessments (PIA)  Coordinators of an upcoming conference, attended by federal government IT managers and staff, invited you to participate in a panel presentation about privacy. For this activity, prepare a 5 to 7 paragraph briefing statement which answers

Proj4-final

Project 4: Postmigration Activities  Step 1: Postmigration Activities Overview  Like any software development project, migration projects require careful planning to ensure success. This planning includes the postmigration testing and maintenance phase. Start this project by researching and planning the  postmigration activities that will be required to get BallotOnline’s migrated workloads in

Discussion-4

Discussion: Postmigration Approaches and Activities Contains unread posts Now that you have completed BallotOnline’s cloud migration, you will discuss the cloud postmigration activities and approaches. You should cover the following areas: · What is the business impact after the migration? · How will you manage service-level agreements in the cloud?

D 3 of 360

Follow the attach instructions to complete this work. How does FedRAMP help agencies ensure that Digital Government services are secure?   Must post first. Subscribe The format for your week 3 discussion is a backgrounder (“briefing paper”). Background papers are summaries of issues provided to help decision-makers/leaders/managers make decisions. Decision-makers

D 2 of 360

Follow the attach document to complete this work.  Briefing Statement: Security Implications of OPEN Data   Representatives from the  Joint Committee on Cybersecurity and Information Technology have asked you to provide a briefing as part of their “Cyber Scholars Day.” The committee is sponsoring this day of briefings and outreach for

D 1 of 360

Follow the attach document to complete this work. Growing Reliance on Digital Government Services   Your 1 discussion short paper assignment is to write a  workplace newsletter article. As you work on this type of discussion item, think about the newsletters you receive in your workplace. Are they engaging? Do they

Week 3 Discussion: PUMP Versus PMBOK® Guide Approach

I put the links to both the text and the PMBOK Guide, it is through my school library so it may not come up without my login at the botton of the instructions also in bold letters is the information to both the course text and the guide please let

wk 9 distance edu

PLEASE SEE IF YOU CAN LOOK UP THE READING IN THE FILE PORTION, I WAS NOT ABLE TO PULL IT UP UNFORTUNATELY!  After reading “Applying “Design Thinking” in the Context of Media Management EducationLinks to an external site.,” think about all aspects of learning online: activities, workload, faculty-to-learner communication, and