Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9109565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:04:18+00:00 2026-06-17T03:04:18+00:00

I am creating a small game of Final Fantasy characters, in which I input

  • 0

I am creating a small game of Final Fantasy characters, in which I input the name of who I would like to “fight” I have each character (only 5 of them) as a subclass to a superclass called Stats in which the variables (non static) and getters/setters are defined.

The code all works as I would like, but I don’t like it all being in One huge class.

The Main method is here;

package com.George.revision;

import java.util.Random;

import com.George.characters.Cloud;
import com.George.characters.Squall;
import com.George.characters.Stats;
import com.George.characters.TheEnemy;
import com.George.characters.ThePlayer;
import com.George.characters.Tidus;
import com.George.characters.Yuna;
import com.George.characters.Zidane;
import com.George.input.GetInput;
import com.George.input.ListNames;



public class Main {


    public static void main(String[] args) {

        ListNames.listNames();


        Stats clo = new Cloud();
        Stats squ = new Squall();
        Stats zid = new Zidane();
        Stats tid = new Tidus();
        Stats yun = new Yuna();

        String versus = GetInput.getInput("\nWhich of these Characters would you like to go up against?");

        Stats ene1 = new TheEnemy();


        switch (versus) {
        case "Cloud":
            ene1.setName(Names.CLOUD);
            ene1.setHairColor(Stats.BLONDE);
            ene1.setWep(Weapons.BUSTER_SWORD);
            ene1.setSkill(clo.skill);
            ene1.setAp(clo.ap);
            ene1.setStr(clo.str);
            ene1.setMag(clo.mag);
            break;
        case "Squall":
            ene1.setName(Names.SQUALL);
            ene1.setHairColor(Stats.BLACK);
            ene1.setWep(Weapons.LIONHEART);
            ene1.setSkill(squ.skill);
            ene1.setAp(squ.ap);
            ene1.setStr(squ.str);
            ene1.setMag(squ.mag);
            break;
        case "Zidane":
            ene1.setName(Names.ZIDANE);
            ene1.setHairColor(Stats.LIGHTBROWN);
            ene1.setWep(Weapons.THIEF_DAGGER);
            ene1.setSkill(zid.skill);
            ene1.setAp(zid.ap);
            ene1.setStr(zid.str);
            ene1.setMag(zid.mag);
            break;
        case "Tidus":           
            ene1.setName(Names.TIDUS);
            ene1.setHairColor(Stats.BLONDE);
            ene1.setWep(Weapons.CALADBOLG);
            ene1.setSkill(tid.skill);
            ene1.setAp(tid.ap);
            ene1.setStr(tid.str);
            ene1.setMag(tid.mag);
            break;
        case "Yuna":
            ene1.setName(Names.YUNA);
            ene1.setHairColor(Stats.DARKBROWN);
            ene1.setWep(Weapons.NIRVANA);
            ene1.setSkill(yun.skill);
            ene1.setAp(yun.ap);
            ene1.setStr(yun.str);
            ene1.setMag(yun.mag);
            break;
        default:
            System.out.println("You did not enter a valid character name");
            break;


        } 
        System.out.println("You have chosen to face " + ene1.name);
        System.out.println("Enemy Skill = " + ene1.skill + " Enemy Weapon = " + ene1.wep);



        System.out.println("Enemy Skill = " + ene1.skill + " Enemy Weapon = " + ene1.wep);

        int eneTotal = ene1.skill + ene1.ap + ene1.str + ene1.mag;

        Stats player = new ThePlayer();

        String plN = GetInput.getInput("What is your name?");
        player.playerName = plN;        
        System.out.println("So Your name is " + player.playerName);

        String plWep = GetInput.getInput("What is your Weapon's name?");
        player.playerWep = plWep;
        System.out.println("So your Weapon is " + player.playerWep);

        Random generator = new Random();
        int plSkill = generator.nextInt(10);
        player.skill = plSkill;
        System.out.println("Your skill level is " + player.skill);

        Random gn = new Random();
        int plAp = gn.nextInt(10 - 5) + 5;
        System.out.println("So your Attack Power is " + plAp);
        player.ap =  plAp;

        Random gns = new Random();
        int plStr = gns.nextInt(10);
        System.out.println("So your Strength is " + plStr);
        plStr = player.str;

        Random gnm = new Random();
        int plMag = gnm.nextInt(10 - 5) + 5;
        player.mag = plMag;
        System.out.println("So your Magic is " + player.mag);


        int plHax = 15;
        double doubleResult = plHax;


        double ene1Hax = 3.99;
        int intResult = (int)ene1Hax;


        double doubleValue = 6.99;
        Double doubleObj = new Double(doubleValue);
        int intR = doubleObj.intValue();

        System.out.println(intR);

        int plyrTotal = player.skill + player.ap + player.str + player.mag;

        if (plyrTotal > eneTotal) {
            System.out.println("Congratulations you beat " + ene1.name + " Please Play Again!" );

        } else if (plyrTotal == eneTotal) {
            System.out.println("You drew with " + ene1.name + " Play again and Win!");
        }
        else
        {
            System.out.println("You were not succesful this time " + ene1.name + " Defeated you by " + (eneTotal - plyrTotal) + " Please Try Again");

        }


    }

}

Now after this I have a whole lot more code generating random numbers for the players “stats”, and the character, and then matching the total values of their stats to determine “a winner” which I would like to put in a separate class. My issue is,

how do I get ene1 in a separate class with the values that are input in the switch statement in the Main class.

Updated to full main method just for clarity

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:04:20+00:00Added an answer on June 17, 2026 at 3:04 am

    You can just pass it into a method (or constructor) of that class as you would any other variable or text. I.e.

     clo.setOpponent(ene1);
    

    Then have the implementation of setOpponent be like this

     class Stats
     {
          private Stats opponent;
          //ALL OF YOUR OTHER CODE AND METHODS GO HERE
    
          public void setOpponent(Stats enemy)
          {
              opponent = enemy;
          }
     }
    

    This doesn’t take into account the poor OO design of your application, it only answers your question. Better design comes with more practice and some studying (look up IS-A and HAS-A relationships to help with basic OO design)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a small game just like the game Reversi/Othello I have managed to
I'm creating pages for a small web-based game which must have some background music
I am creating a small Yahtzee game and i have run into some regex
A new game server just came out which our company would like to offer
I am creating a game where i have small particles. Their number is changing
I am creating a small game, I will have some objects on the map
I'm creating a small game and I have a peace of code that collects
I'm creating a small kids game, where I have a map of ireland in
I am creating a small game for students, and in a place, it has
I'm creating a leader board (a small results table) for a Javascript game i've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.