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