1
Java Thread (Help,discussion,tips+pointers, code sharing)
Hello I think we need a thread for discussion about Java. Here we can share code, talk about projects, ask questions, answer questions, and discuss Java in general.
I am not particularly knowlegable in Java myself but I hope we can get some experts
like SourC00kie to contribute. Begin discussion!
I am not particularly knowlegable in Java myself but I hope we can get some experts
like SourC00kie to contribute. Begin discussion!
Create an account or sign in to comment.
7
1
If anyone where to help you we would need the code the error is from.
1
10:09 PM [SEVERE] java.net.SocketException: Socket closed
10:09 PM [INFO] Connection reset
10:09 PM [SEVERE] at java.net.SocketOutputStream.socketWrite(Unknown Source)
10:09 PM [SEVERE] at java.net.SocketOutputStream.write(Unknown Source)
10:09 PM [SEVERE] at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
10:09 PM [SEVERE] at java.io.BufferedOutputStream.flush(Unknown Source)
10:09 PM [SEVERE] at java.io.DataOutputStream.flush(Unknown Source)
10:09 PM [SEVERE] at net.minecraft.server.NetworkWriterThread.run(Sourc eFile:104)
HOW DO I FIX THIS RRRRBLRBLRLLBRLBLLLRBLBLRBL.
10:09 PM [INFO] Connection reset
10:09 PM [SEVERE] at java.net.SocketOutputStream.socketWrite(Unknown Source)
10:09 PM [SEVERE] at java.net.SocketOutputStream.write(Unknown Source)
10:09 PM [SEVERE] at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
10:09 PM [SEVERE] at java.io.BufferedOutputStream.flush(Unknown Source)
10:09 PM [SEVERE] at java.io.DataOutputStream.flush(Unknown Source)
10:09 PM [SEVERE] at net.minecraft.server.NetworkWriterThread.run(Sourc eFile:104)
HOW DO I FIX THIS RRRRBLRBLRLLBRLBLLLRBLBLRBL.
1
not a java wizard, but i know some
i like this thread
i like this thread
1
Are there any Java wizards who can help?
1
Could you explain this some more? Does this go in a new class? Do I keep the code in AccountDemo.java? For the [...] parts do I put the same code every time? Which code?
1
DusteroftheCenturybump!
Here ill start us off with something://AccountDemo.java//
public class AccountDemo
{
public static void main(String args[])
{
//Creates a blank account
Account my_account = new Account();
//Sets starting Account balance
my_account.deposit(1000.00);
//Tells it to display the starting balance
System.out.println ("Credits: " +
my_account.getbalance());
//Tells it to take away money
my_account.withdraw(344.00);
//Tells it to display the end balance
System.out.println ("Remaining Credits " +
my_account.getbalance());
}
}
Where it says "my_account.withdraw(Numbers)" How do I change that value while in the program without changing the code?
You have to make it accept a string from your keyboard:
java.io*
[...]
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
[...]
System.out.println ("Current balance: " + my_account.getbalance());
my_account.withdraw = console.readLine("How much would you like to withdraw?");
System.out.println ("You are withdrawing " + my_account.withdraw() + ".");
System.out.println ("Updated balance: " + my_account.getbalance());
[...]
My Java is a little rusty, but that's the basics. Where "[...]" is would be the rest of your code.
*waits for someone to correct my code*
1
bump!
Here ill start us off with something:
Where it says "my_account.withdraw(Numbers)" How do I change that value while in the program without changing the code?
Here ill start us off with something:
//AccountDemo.java//
public class AccountDemo
{
public static void main(String args[])
{
//Creates a blank account
Account my_account = new Account();
//Sets starting Account balance
my_account.deposit(1000.00);
//Tells it to display the starting balance
System.out.println ("Credits: " +
my_account.getbalance());
//Tells it to take away money
my_account.withdraw(344.00);
//Tells it to display the end balance
System.out.println ("Remaining Credits " +
my_account.getbalance());
}
}
//Account.java//
public class Account
{
protected double balance;
public Account( double amount )
{
balance = amount;
}
public Account()
{
balance = 0.0;
}
public void deposit( double amount )
{
balance += amount;
}
public double withdraw( double amount )
{
if (balance >= amount)
{
balance -= amount;
return amount;
}
else
return 0.0;
}
public double getbalance()
{
return balance;
}
}
Where it says "my_account.withdraw(Numbers)" How do I change that value while in the program without changing the code?