Submit the source code & output of these programs on eCampus or demo the programs to the instructor during open lab.


1
.  Complete the overloaded methods to make this program work.

public class methods
{
   public static void main (String[] args)
   {
      int A=1, B=10, C=-5, D=20;
      System.out.println("The largest of A and B is " + Largest(A,B));
      System.out.println("The largest of A, B and C is " + Largest(A,B,C));
      System.out.println("The largest of A, B, C and D is " + Largest(A,B,C,D));
      System.out.println("The product of A and B is " + Product(A,B));
      System.out.println("The product of A, B and C is " + Product(A,B,C));
      System.out.println("The product of A, B, C and D is " + Product(A,B,C,D));
   }
   // put the methods here
}


2
. Write a class definition for a Pyramid.

It should have these variables:  double Width, Height
It should have these methods:  SetWidthHeight(double W, double H),  GetVolume(),  GetSurfaceArea()

Use the following main program to demo your Pyramid class:

import java.util.*;

public class egypt
{
   public static void main(String[] args)
   {
      Scanner in = new Scanner(System.in);
      Pyramid Luxor = new Pyramid();
      double W, H;
      System.out.println("Enter pyramid's width in meters:");
      W = in.nextDouble();
      System.out.println("Enter pyramid's height in meters:");
      H = in.nextDouble();

      Luxor.SetWidthHeight(W, H);
      System.out.println("Volume = " + Luxor.GetVolume() + " cubic meters") ;
      System.out.println("Surface area = " + Luxor.GetSurfaceArea() + " square meters") ;
   }
}

// put the Pyramid class here


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

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.
String Type Enemy type such as "Orc" or "Troll" if you are doing a Middle Earth theme
int HP Hitpoints of the enemy.  The enemy is dead 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;
}

Use the following main program to demo your Enemy class:

public class game
{
   public static void main(String[] args)
   {
      Enemy E1 = new Enemy("Orc");
      Enemy E2 = new Enemy("Troll");
      Enemy E3 = new Enemy("Dragon");

      System.out.println("There's a " + E1.Race + " with " + E1.HP + " HP at " + E1.X + "," + E1.Y);
      System.out.println("There's a " + E2.Race + " with " + E2.HP + " HP at " + E2.X + "," + E2.Y);
      System.out.println("There's a " + E3.Race + " with " + E3.HP + " HP at " + E3.X + "," + E3.Y);
   }
}
// put the Enemy class here