Alright so I have a hw on multiple classes and I am having trouble with getting input from 1 to another. Now I don't know what the best way to do this so I am having the class ask for the input(error is here can't make it do it) and then having that outputted to a string in the driver program.
Bankaccount ClassDriver Program-Yes i started thinking to much and got ahead of myselfimport java.io.InputStream; import java.util.Scanner; public class Bankaccount { private String name; private int balance; public Bankaccount() { int balance = 1000; Scanner keyboard = new Scanner(System.in); String name = keyboard(System.in); } public String showName(){ return name ; } public int deposit(){ return balance += deposit(); } public int withdraw(){ return balance -= withdraw(); } }
import java.util.Scanner; public class Playingdice { /** * @param args */ public static void main(String[] args) { System.out.println("Playing A Game Of Dice"); Scanner keyboard = new Scanner(System.in); //int wager1 = Integer.parseInt(keyboard.nextLine()); Bankaccount b1 = new Bankaccount(); Bankaccount b2 = new Bankaccount(); //Names String name1; name1 = b1.showName(); System.out.println("PLease enter a name for Account 1: " + b1.nameShow()); String name2; name2 = b2.showName(); System.out.println("PLease enter a name for Account 2: " + name2); //int balance1 = b1.balance(); //int balance2 = b2.balance(); //int wager = b1.withdraw(); //int wager2 = b2.withdraw(); //int win1 = b1.deposit(); //int win2 = b2.deposit(); Die d1 = new Die(); Die d2 = new Die(); int r1 = d1.roll(); int r2 = d2.roll(); int total = r1 + r2; } }