OK了:
package com;
public class A2Program {
private static final String STAGE_INFO = "COMPSCI 101 Asst 2 - STAGE 1\n";
public void start() {
System.out.println(STAGE_INFO);
testPlayerWithStrategy(10);
testPlayerWithStrategy(20);
}
// This method tests the getStrategy(), getGameTotal() and
// addToGameTotal() methods of the Player class
private void testPlayerWithStrategy(int strategy) {
Player p = new Player(strategy);
System.out.println("A Player with a strategy of " + strategy);
System.out.println(" " + p.getStrategy());
System.out.println(" " + p.getGameTotal());
p.addToGameTotal(5);
p.addToGameTotal(3);
System.out.println(" " + p.getGameTotal());
}
public static void main(String []args)
{
(new A2Program()).start();
}
}
class Player
{
public int strategy;
public int total;
public Player(int strategy)
{
this.strategy=strategy;
this.total=0;
}
public int getStrategy()
{
return this.strategy;
}
public int getGameTotal()
{
return this.total;
}
public void addToGameTotal(int num)
{
this.total+=num;
}
}
public class A2Program {
private static final String STAGE_INFO = "COMPSCI 101 Asst 2 - STAGE 1\n";
public void start() {
System.out.println(STAGE_INFO);
testPlayerWithStrategy(10);
testPlayerWithStrategy(20);
}
private void testPlayerWithStrategy(int strategy) {
Player p = new Player(strategy);
System.out.println("A Player with a strategy of " + strategy);
System.out.println(" " + p.getStrategy());
System.out.println(" " + p.getGameTotal());
p.addToGameTotal(5);
p.addToGameTotal(3);
System.out.println(" " + p.getGameTotal());
}
public static void main(String[] args) {
new A2Program().start();
}
}
哥们儿 你能把完整的程序贴出来吗