我剛開始在iTunes上學習斯坦福CS106a課程,但我遇到了Eclipse的問題。這裏是我的代碼:需要幫助在Eclipse中使用ACM Java庫來運行程序
/*
* File: Add2Integers.java
* -----------------------
* A simple ConsoleProgram to add two integers
* and display their total.
*/
import acm.program.*;
public class Add2Integers extends ConsoleProgram {
public void run() {
/* So all y'all in the back can see! */
setFont("DejaVuSerif-BOLD-24");
println("This program adds two numbers.");
int n1 = readInt("Enter n1: ");
int n2 = readInt("Enter n2: ");
int total = n1 + n2;
println("The total is " + total + ".");
}
}
當我嘗試運行它,我得到了部分不包含小應用程序的消息。我認爲這與import acm.program
有關。
我下載了acm工具包,並嘗試將program.java
文件添加到我的根文件夾中,構建路徑,對整個acm文件夾執行相同操作,沒有任何效果。
我只需要幫助讓這個簡單的程序啓動和運行,以便我可以開始學習。
我正在運行OSX 10.8。
當我添加這個時沒有改變。我看到教授運行這個相同的程序,在Eclipse中不需要額外的代碼。如果你可以給我一步一步的指示,我需要做些什麼來實現這個目標? – Kris 2013-03-15 17:32:30