PLEASE REVIEW THE INFORMATION BELOW  Submit the source code .java files on Ecampus under the “Submit Homework” menu option. 1. In a

PLEASE REVIEW THE INFORMATION BELOW 

Submit the source code .java files on Ecampus under the “Submit Homework” menu option.


1.
 In a single file named shapes.java, write class definitions for a square based 
Pyramid and a 
Cone.  These classes should have a constructor to pass values for the class variables.

Pyramid class variables:
  Width, 
Height
Pyramid class methods:  
getVolume(), 
 getSurfaceArea()
Cone class variables:  
Radius, Height
Cone class methods:  
getVolume(), 
 getSurfaceArea()

Your main program should ask the user to enter values for each of the variables and output the volume and surface area of the pyramid and cone.  The code below will help you get started with the main program.

Enemy Class

Variables

Description

int Xpos, Ypos

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

char Avatar

The character that will be displayed on the screen representing the type of enemy.

String Type

Enemy type such as “Orc” or “Troll”.

int HP

Hitpoints of the enemy.  The enemy is deceased when HP is 0.

int Attack

Attack rating of the enemy: The higher the number, the more damage is does.

int Armor

Armor rating of the enemy: The higher the armor, the less damage it takes.

Methods

Description

Enemy(String theType)

Constructor that takes 1 parameters – theType

Initialize your class variable to the parameter:
Type = theType;

Set Xpos and Ypos to random numbers from 0 to 9.

In the constructor, you will set these things based on the Type:  Avatar, HP, Attack, Armor.  For example:
if (Type.equals(“Orc”))

   Avatar = ‘O’;  HP = 50;  Attack = 5;  Armor = 20;
}

import java.util.*;
public class shapes
{
   public static void main(String[] args)
   {
      // ask user to enter values for pyramid Width and Height here

      // declare instance of the Pyramid class and send width and height as parameters
      Pyramid Luxor = new Pyramid(Width, Height);

      // output volume and surface area of pyramid
      System.out.println(“Volume = ” + Luxor.getVolume() + ” cubic meters”) ;
      System.out.println(“Surface area = ” + Luxor.getSurfaceArea() + ” square meters”);

      // do the same thing with the Cone class
   }
}

// Pyramid class goes here

// Cone class goes here

2.  Write a class definition for an 
Enemy for your game.java

Write a main program to demonstrate your Enemy class:

1.  Create an object of each of enemy (at least 3 different types).
2.  Create a 10×10 array of characters named World (same as in homework 2).
3.  Put the Avatar character of each of the 3 types of enemies into the World.
4.  Display World (same as in homework 2)

Example output below showing a dragon, orc, and troll in random locations.

. . . D . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . O . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . T . . .
. . . . . . . . . .
. . . . . . . . . .
  IF THE ABOVE INFORMATION IS CONFUSING PLEASE SEE THE BELOW PICTURE

image1.png

image2.png

image3.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

i need someone to do this homework for me  Technische Informatik 1 Wintersemester 2024/2025 Übungsblatt 9 Bitte Beachten! Diese Hausübung ist

i need someone to do this homework for me  Technische Informatik 1 Wintersemester 2024/2025 Übungsblatt 9 Bitte Beachten! Diese Hausübung ist eine Zulassungsvorraussetzung für die Klausur. Bitte laden sie ihre Lösung entsprechend der Aufgabenbeschreibung in Moodle über den dazu vorgesehenen Punkt bis zum 08.01.25 23:59Uhr auf Moodle hoch. Übung 9

Follow the attach instructions to complete this work. Analyzing a Business Function – Project Management   Must post first. Subscribe Nofsinger

Follow the attach instructions to complete this work. Analyzing a Business Function – Project Management   Must post first. Subscribe Nofsinger Consulting Services uses Project Management techniques to manage client engagements. One of the primary responsibilities of the engagement project managers is ensuring that the advisory services and associated written

Kenya Forestry College [email protected] P.O. BOX 8 -20203, Londiani Tel .No.0202349901, 07232262 APPLICATION FOR TRAINING PROGRAMMES

Kenya Forestry College [email protected] P.O. BOX 8 -20203, Londiani Tel .No.0202349901, 07232262 APPLICATION FOR TRAINING PROGRAMMES 2019/2020 Applications are invited for the following training programmes to be offered at Kenya Forestry College, Londiani commencing on the given dates. S/ n Programme Entry Requirements Duration Commencement Date Total Cost (Ksh) 1