Hello!

I am starting a small text based game, I have created my set and get methods for my player class:

import java.util.*;


public  class player extends main{

    /*
     * Player attributes:
     * Name
     * Weight
     * Morale
     * Money
     */

    //PLAYER ATTRIBUTES
    private String name;
    private int weight;
    private int morale;
    private int money;
    private int exp;

    //CREATES OBJECT OF PLAYER 
    public player(String sName, int iWeight, int iMorale, int iMoney, int iExp) {

        name = sName;
        weight = iWeight;
        morale = iMorale;
        money = iMoney;
        exp = iExp;
    }


    //GET AND SET NAME
    public void setName(String sName) {
         name = sName;
    }
    public String getName() {
        return name;
    }

    //GET AND SET WEIGHT
    public void setWeight(int iWeight) {
         weight = iWeight;
    }
    public int getWeight() {
        return weight;
    }

    //GET AND SET MORALE
    public void setMorale(int iMorale) {
         morale = iMorale;
    }
    public int getMorale() {
        return morale;
    }

    //GET AND SET MONEY
    public void setMoney(int iMoney) {
         money = iMoney;
    }
    public int getMoney() {
        return money;
    }   

    //GET AND SET EXP
    public void setExp(int iExp) {
         exp = iExp;
    }
    public int getExp() {
        return exp;
    }   

}   

and then create an object of the player class in my main class:

public class main {


    public static void main(String args[]) {


        /*
         * Creates a object of player with the pre-determined values, name is added later.
         * Weight starts at 150lbs, 20/100 Morale, $100 and 0 Exp
         */

        player newPlayer =  new player("", 150, 20, 100, 0);
        player.


    }

Now, my problem is how do I 'progress' the game? Would this all be done sequentially through the main method?

E.G:

public static void main(String args[]) {
        SYSOUT:("Hello Welcome To The Game");

        player newPlayer =  new player("", 150, 20, 100, 0);

        SYSOUT("What is your name?");
        name = scanner.nextLine();
        player.setName(name);

        SYSOUT("Hello " + player.getName);

        SYSOUT("You eat 5 cheeseburgers and gain 10lbs");
        player.getWeight();
        player.setWeight(weight+10);

        SYSOUT("You have gained 10exp from eating 5 cheeseburgers");
        player.getExp();
        player.setExp(exp+10);


        [eat another meal]

        [event happens]

        [eat another meal] etc etc


    }

Would this all have to be pre-designed sequentially? I cannot wrap my head around how I approach this.

If someone could give a brief overview of how I get the game rolling (and keep rolling) once the user runs the program that would be fantastic

hmmm, the behind any game is a loop. Including 2d and 3d games and even text based games. For a very simple text based game
your main method is probably the way it should be. However i would recommend implementing seperate functions for certain parts of your game that are used often. Such as an add player function to instantiate a new player. If you want to understand the basics of a game i would recommend looking around stuff like this :
http://obviam.net/index.php/a-very-basic-the-game-loop-for-android/

Whilst its in android it outlines the fundamentals such as recieving input,updating and incase of 3d or graphical contexts rendering. All in all a game really is only a loop.

Pulling on an example from wikipedia :

"while( user doesn't exit )
check for user input
run AI
move enemies
resolve collisions
draw graphics
play sounds
end while"

Outlines the basis for most games on the market, There are a lot of examples but for a text game its really along the lines of what you already have.

your name?");
name = scanner.nextLine();
player.setName(name);

SYSOUT:("Hello Welcome To The Game");
player newPlayer = new player("", 150, 20, 100, 0);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.