Merge remote-tracking branch 'origin/master'

# Conflicts:
#	out/production/TaipanClone/ShipWarfare.class
This commit is contained in:
Vikram
2019-02-25 18:33:26 -07:00
7 changed files with 64 additions and 18 deletions

View File

@@ -1,7 +1,12 @@
# TaipanClone # TaipanClone
Computer Science 233 project, Winter 2019 Computer Science 233 project, Winter 2019
To run the program, please go to src>start.java and run that program. How to run:
If you are using intellij, extract "TaipanClone-master.zip", and open the "TaipanClone-master" folder in intellij. Also set up the SDK. Then, run main.java.
If you are using the command line, extract "TaipanClone-master.zip", and open the "TaipanClone-master" folder. Open your terminal and change its directory to the "src" folder within "TaipanClone-master" folder. Then, type in "javac *.java", this compiles all the necessary files. Now, run main.java using "java main".
Additional information:
For input, the program usually takes the first letter of whichever option you need to select. Example: For input, the program usually takes the first letter of whichever option you need to select. Example:
What would you like to buy? Valid inputs are "O" (for Opium), "S" (for Silk), "A" (for Arms), "G" (for General cargo). What would you like to buy? Valid inputs are "O" (for Opium), "S" (for Silk), "A" (for Arms), "G" (for General cargo).

Binary file not shown.

View File

@@ -1,4 +1,3 @@
import java.sql.SQLOutput;
import java.util.Scanner; import java.util.Scanner;
public class Bank{ public class Bank{

View File

@@ -211,6 +211,7 @@ public class Player {
public void gameOver(){ public void gameOver(){
System.out.flush(); System.out.flush();
System.out.println("Game over"); System.out.println("Game over");
System.exit(0);
} }
} }

View File

@@ -3,22 +3,42 @@ public class Start
{ {
private Player player; private Player player;
/**
* getter method for obtaining a player object.
*
* @return returns player object
*/
public Player getPlayer() { public Player getPlayer() {
Player playerTemp = new Player(player); Player playerTemp = new Player(player);
return playerTemp; return playerTemp;
} }
/**
* setter method that takes in a Player object as an argument.
*
* @param player object of the class Player
*/
public void setPlayer(Player player) { public void setPlayer(Player player) {
Player playerTemp = new Player(player); Player playerTemp = new Player(player);
this.player = playerTemp; this.player = playerTemp;
} }
/**
* Asks the user to input the name that they would like to be called in the game
*
* @param name the name that you would like to be called in the game
*/
public void setFirm (String name) { public void setFirm (String name) {
if (name.length() <= 22) { if (name.length() <= 22) {
player.setName(name); player.setName(name);
} }
} }
public void intialize()
/**
* Initializes the game by asking for your name and if you would like to start with either: 1) money and a debt or
* 2) guns and no cash/debt.
*/
public void initialize()
{ {
Scanner userInput = new Scanner(System.in); Scanner userInput = new Scanner(System.in);
System.out.println("Taipan, \nWhat will you name your firm:"); System.out.println("Taipan, \nWhat will you name your firm:");
@@ -46,6 +66,10 @@ public class Start
} }
/**
* Copy constructor.
* @param player object of the class Player
*/
public Start(Player player) public Start(Player player)
{ {
Player playerTemp = new Player(player); Player playerTemp = new Player(player);

View File

@@ -20,20 +20,37 @@ public class loanShark {
public void loanMoney() { public void loanMoney() {
boolean keepGoing = true; boolean keepGoing = true;
while(keepGoing) { while(keepGoing) {
int loanAsk = 0;
System.out.println("Please enter how much you would like to borrow");
Scanner keyboard = new Scanner(System.in);
loanAsk = keyboard.nextInt();
if(loanAsk <= 2*(player.getMoney() - player.getDebt())) {
player.setDebt(player.getDebt() + loanAsk);
player.setMoney(player.getMoney() + loanAsk);
}
//updated
else{
System.out.println("Sorry you can't be loaned that much");
break;
}
String check; String check;
Scanner keyboard = new Scanner(System.in);
System.out.println("Would you like to return money or borrow money?");
check = keyboard.nextLine();
if(check.equalsIgnoreCase("r")){
int returnAsk = 0;
System.out.println("Please enter how much you would like to return?");
returnAsk = keyboard.nextInt();
if(returnAsk <= player.getDebt() && returnAsk >= 0) {
player.setDebt(player.getDebt() - returnAsk);
player.setMoney(player.getMoney() - returnAsk);
}//updated
else if(returnAsk > player.getDebt()){
System.out.println("You don't need to return that much!");
}else{
System.out.println("You can't return a negative amount.");
}
}else if(check.equalsIgnoreCase("b")){
int loanAsk = 0;
System.out.println("Please enter how much you would like to borrow");
loanAsk = keyboard.nextInt();
if(loanAsk <= 2*(player.getMoney() - player.getDebt())&& loanAsk >= 0) {
player.setDebt(player.getDebt() + loanAsk);
player.setMoney(player.getMoney() + loanAsk);
}//updated
else{
System.out.println("Sorry you can't be loaned that much");
break;
}
}
System.out.println("Would you like to do any other business? Y / N?"); System.out.println("Would you like to do any other business? Y / N?");
check = keyboard.nextLine(); check = keyboard.nextLine();
check = keyboard.nextLine(); check = keyboard.nextLine();
@@ -46,4 +63,4 @@ public class loanShark {
} }
} }
} }
} }

View File

@@ -15,7 +15,7 @@ public class main {
public void start(Start start){ public void start(Start start){
start.setPlayer(player); start.setPlayer(player);
start.intialize(); start.initialize();
player = start.getPlayer(); player = start.getPlayer();
} }