bunch of revisions, still in progress

This commit is contained in:
Vikram
2019-02-24 15:58:17 -07:00
parent dabedd8a72
commit 210f64cb2f
7 changed files with 358 additions and 339 deletions

View File

@@ -1,52 +1,52 @@
import java.util.Scanner;
public class Bank{
private Player player;
public void setPlayer(Player player) {
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public Player getPlayer(){
Player playerDummy = new Player(player);
return playerDummy;
}
public Bank(Player player){
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public int promtMoney() {
int addVal = 0;
int retVal = 0;
System.out.println("Please enter an amount");
Scanner keyboard = new Scanner(System.in);
addVal = keyboard.nextInt();
if(addVal >= 0) {
retVal = addVal;
}
return retVal;
}
public void addMoney() {
int addMon = promtMoney();
if(addMon >= 0) {
player.setBank(promtMoney() + player.getMoney());
}
}
public void removeMoney() {
int subMon = promtMoney();
if(subMon <= player.getMoney()) {
player.setBank(subMon - player.getMoney());
}
}
public void addInterest() {
setBank((int)((player.getBank() * 1.05)));
}
}
import java.util.Scanner;
public class Bank{
private Player player;
public void setPlayer(Player player) {
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public Player getPlayer(){
Player playerDummy = new Player(player);
return playerDummy;
}
public Bank(Player player){
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public int promtMoney() {
int addVal = 0;
int retVal = 0;
System.out.println("Please enter an amount");
Scanner keyboard = new Scanner(System.in);
addVal = keyboard.nextInt();
if(addVal >= 0) {
retVal = addVal;
}
return retVal;
}
public void addMoney() {
int addMon = promtMoney();
if(addMon >= 0) {
player.setBank(promtMoney() + player.getMoney());
}
}
public void removeMoney() {
int subMon = promtMoney();
if(subMon <= player.getMoney()) {
player.setBank(subMon - player.getMoney());
}
}
public void addInterest() {
player.setBank((int)((player.getBank() * 1.01)));
}
}

View File

@@ -29,22 +29,6 @@ public class Player {
this.debt = player.debt;
}
public Player(){
}
public Player(Player player){
this.bank = player.bank;
this.money = player.money;
this.opiumHeld = player.opiumHeld;
this.silkHeld = player.silkHeld;
this.generalHeld = player.generalHeld;
this.armsHeld = player.armsHeld;
this.location = player.location;
this.guns = player.guns;
this.HP = player.HP;
}
public String getName() {
return name;
}

View File

@@ -1,45 +1,46 @@
import java.util.Scanner;
public class Start
{
private Player player;
public Player getPlayer() {
Player playerTemp = new Player(player);
return playerTemp;
}
public void setPlayer(Player player) {
Player playerTemp = new Player(player);
this.player = playerTemp;
}
public void setFirm (String name) {
System.out.println("Taipan, \nWhat will you name your \nFirm: ");
if (name.length() <= 22) {
player.setName(name);
}
}
public void main(String[] args)
{
System.out.println("Do you want to start . . .\n1) With cash (and a debt)\n>> or <<\n" +
"With five guns and no cash (But no debt!)\n? ");
Scanner userInput = new Scanner(System.in);
if (userInput.nextInt() == 1)
{
player.setMoney(400);
player.setDebt(5000);
}
if (userInput.nextInt() == 2)
{
player.setGuns(5);
}
}
public Start(Player player)
{
Player playerTemp = new Player(player);
this.player = playerTemp;
}
}
import java.util.Scanner;
public class Start
{
private Player player;
public Player getPlayer() {
Player playerTemp = new Player(player);
return playerTemp;
}
public void setPlayer(Player player) {
Player playerTemp = new Player(player);
this.player = playerTemp;
}
public void setFirm (String name) {
if (name.length() <= 22) {
player.setName(name);
}
}
public void intialize()
{
Scanner userInput = new Scanner(System.in);
System.out.println("Taipan, \nWhat will you name your \nFirm: ");
setFirm(userInput.nextLine());
System.out.println("Do you want to start . . .\n1) With cash (and a debt)\n>> or <<\n" +
"With five guns and no cash (But no debt!)\n? ");
if (userInput.nextInt() == 1)
{
player.setMoney(400);
player.setDebt(5000);
}
if (userInput.nextInt() == 2)
{
player.setGuns(5);
}
}
public Start(Player player)
{
Player playerTemp = new Player(player);
this.player = playerTemp;
}
}

View File

@@ -1,154 +1,154 @@
import java.util.Scanner;
public class Warehouse {
private int wOpium = 25;
private int wSilk = 0;
private int wGeneral = 0;
private int wArms = 0;
private String good = "";
private int finalAmount = 0;
private Player player;
public void setPlayer(Player player) {
Player playerDumy = new Player(player);
this.player= playerDumy;
}
public Player getPlayer(){
Player playerDummy = new Player(player);
return playerDummy;
}
public Warehouse(Player player){
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public void addAmount(String good, int amount) {
int held = 0;
if (amount > 0) {
if (this.good.equalsIgnoreCase("O")) {
this.wOpium += amount;
held = player.getOpiumHeld();
player.setOpiumHeld(held - amount);
System.out.println(player.getOpiumHeld());
}
else if(this.good.equalsIgnoreCase("S")) {
this.wSilk += amount;
held = player.getSilkHeld();
player.setSilkHeld(held - amount);
}
else if(this.good.equalsIgnoreCase("G")) {
this.wGeneral += amount;
held = player.getGeneralHeld();
player.setGeneralHeld(held - amount);
}
else if(this.good.equalsIgnoreCase("A")) {
this.wArms += amount;
held = player.getArmsHeld();
player.setArmsHeld(held - amount);
}
}
else {
System.out.println("Sorry this transfer cannot be made");
}
}
public void removeAmount(String good, int amount) {
int held = 0;
if (amount > 0) {
if (this.good.equalsIgnoreCase("O")) {
this.wOpium -= amount;
held = player.getOpiumHeld();
player.setOpiumHeld(held + amount);
}
else if(this.good.equalsIgnoreCase("S")) {
this.wSilk -= amount;
held = player.getSilkHeld();
player.setSilkHeld(held + amount);
}
else if(this.good.equalsIgnoreCase("G")) {
this.wGeneral -= amount;
held = player.getGeneralHeld();
player.setGeneralHeld(held + amount);
}
else if(this.good.equalsIgnoreCase("A")) {
this.wArms -= amount;
held = player.getArmsHeld();
player.setArmsHeld(held + amount);
}
}
else {
System.out.println("Sorry this transfer cannot be made");
}
}
public void showWarehouse() {
System.out.println("Opium : " + this.wOpium);
System.out.println("Silk : " + this.wSilk);
System.out.println("General : " + this.wGeneral);
System.out.println("Arms : " + this.wArms);
}
private void askGood() {
String aGood = "k";
System.out.println("Please enter a good to transfer O, S, G, A :");
Scanner keyboard = new Scanner(System.in);
aGood = keyboard.nextLine();
aGood = aGood.toUpperCase();
this.good = aGood;
}
public void askAddAmount() {
askGood();
int amount = 0;
System.out.println("Please enter the amount of the good you would like to transfer, put negative amount to remove");
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextInt();
if(this.good.equalsIgnoreCase("O") && amount <= player.getOpiumHeld()) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("S") && amount <= player.getSilkHeld()) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("G") && amount <= player.getGeneralHeld()) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("A") && amount <= player.getArmsHeld()) {
finalAmount = amount;
}
}
public void askRemoveAmount() {
askGood();
int amount = 0;
System.out.println("Please enter the amount of the good you would like to remove");
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextInt();
if(this.good.equalsIgnoreCase("O") && amount <= this.wOpium) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("S") && amount <= this.wSilk) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("G") && amount <= this.wGeneral) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("A") && amount <= this.wArms) {
finalAmount = amount;
}
}
public static void main(String[] args){
Warehouse hi = new Warehouse();
hi.showWarehouse();
hi.askRemoveAmount();
hi.removeAmount(hi.good, hi.finalAmount);
hi.showWarehouse();
hi.askAddAmount();
hi.addAmount(hi.good, hi.finalAmount);
hi.showWarehouse();
}
}
import java.util.Scanner;
public class Warehouse {
private int wOpium = 25;
private int wSilk = 0;
private int wGeneral = 0;
private int wArms = 0;
private String good = "";
private int finalAmount = 0;
private Player player;
public void setPlayer(Player player) {
Player playerDumy = new Player(player);
this.player= playerDumy;
}
public Player getPlayer(){
Player playerDummy = new Player(player);
return playerDummy;
}
public Warehouse(Player player){
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public void addAmount(String good, int amount) {
int held = 0;
if (amount > 0) {
if (this.good.equalsIgnoreCase("O")) {
this.wOpium += amount;
held = player.getOpiumHeld();
player.setOpiumHeld(held - amount);
System.out.println(player.getOpiumHeld());
}
else if(this.good.equalsIgnoreCase("S")) {
this.wSilk += amount;
held = player.getSilkHeld();
player.setSilkHeld(held - amount);
}
else if(this.good.equalsIgnoreCase("G")) {
this.wGeneral += amount;
held = player.getGeneralHeld();
player.setGeneralHeld(held - amount);
}
else if(this.good.equalsIgnoreCase("A")) {
this.wArms += amount;
held = player.getArmsHeld();
player.setArmsHeld(held - amount);
}
}
else {
System.out.println("Sorry this transfer cannot be made");
}
}
public void removeAmount(String good, int amount) {
int held = 0;
if (amount > 0) {
if (this.good.equalsIgnoreCase("O")) {
this.wOpium -= amount;
held = player.getOpiumHeld();
player.setOpiumHeld(held + amount);
}
else if(this.good.equalsIgnoreCase("S")) {
this.wSilk -= amount;
held = player.getSilkHeld();
player.setSilkHeld(held + amount);
}
else if(this.good.equalsIgnoreCase("G")) {
this.wGeneral -= amount;
held = player.getGeneralHeld();
player.setGeneralHeld(held + amount);
}
else if(this.good.equalsIgnoreCase("A")) {
this.wArms -= amount;
held = player.getArmsHeld();
player.setArmsHeld(held + amount);
}
}
else {
System.out.println("Sorry this transfer cannot be made");
}
}
public void showWarehouse() {
System.out.println("Opium : " + this.wOpium);
System.out.println("Silk : " + this.wSilk);
System.out.println("General : " + this.wGeneral);
System.out.println("Arms : " + this.wArms);
}
private void askGood() {
String aGood = "k";
System.out.println("Please enter a good to transfer O, S, G, A :");
Scanner keyboard = new Scanner(System.in);
aGood = keyboard.nextLine();
aGood = aGood.toUpperCase();
this.good = aGood;
}
public void askAddAmount() {
askGood();
int amount = 0;
System.out.println("Please enter the amount of the good you would like to transfer, put negative amount to remove");
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextInt();
if(this.good.equalsIgnoreCase("O") && amount <= player.getOpiumHeld()) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("S") && amount <= player.getSilkHeld()) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("G") && amount <= player.getGeneralHeld()) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("A") && amount <= player.getArmsHeld()) {
finalAmount = amount;
}
}
public void askRemoveAmount() {
askGood();
int amount = 0;
System.out.println("Please enter the amount of the good you would like to remove");
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextInt();
if(this.good.equalsIgnoreCase("O") && amount <= this.wOpium) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("S") && amount <= this.wSilk) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("G") && amount <= this.wGeneral) {
finalAmount = amount;
}
else if(this.good.equalsIgnoreCase("A") && amount <= this.wArms) {
finalAmount = amount;
}
}
public static void main(String[] args){
Warehouse hi = new Warehouse(new Player());
hi.showWarehouse();
hi.askRemoveAmount();
hi.removeAmount(hi.good, hi.finalAmount);
hi.showWarehouse();
hi.askAddAmount();
hi.addAmount(hi.good, hi.finalAmount);
hi.showWarehouse();
}
}

View File

@@ -13,6 +13,18 @@ public class main {
player = shop.getPlayer();
}
public void start(Start start){
start.setPlayer(player);
start.intialize();
player = start.getPlayer();
}
public void warehouse(Warehouse warehouse){
warehouse.setPlayer(player);
//warehouse.intialize();
player = warehouse.getPlayer();
}
public void peasantFleet(ShipWarfare warfare) throws Exception {
warfare.setPlayer(player);
warfare.peasantFleetAttack();
@@ -23,6 +35,8 @@ public class main {
main main = new main();
ShipWarfare littyWarfare = new ShipWarfare(main.getPlayer());
TaipanShop littyShop = new TaipanShop(main.getPlayer());
Start start = new Start(main.getPlayer());
main.shop(littyShop);