我有我的主要代碼設置爲一個項目與其他兩個項目(精簡版和專業版)引用它。從庫重寫方法到不同的項目
這就是我想要的Quiz
類尋找精簡版:
class Quiz {
public Quiz {
object1();
object2();
object3();
object4();
}
}
這就是我想要的Quiz
類尋找親:
class Quiz {
public Quiz {
object1();
object2();
object3();
object4();
object5();
object6();
object7();
object8();
}
}
要做到這一點,我需要設置類Quiz
在庫中進行抽象,然後定義它們,但是我想在lite和pro項目中使用?或者我應該將庫定義爲上面的第一個Quiz
示例,然後嘗試在專業版中以某種方式覆蓋它?
編輯
根據下評論,下面是實際的代碼片段。
public class Quiz {
ArrayList<Question> exodus = new ArrayList<Question>(200);
public Quiz() {
exodus.add(new Question("Aaron", "Abraham", "Jacob", "Joseph", 0, "What was the name of Moses' brother?", -1, "Exodus 7:1-2"));
exodus.add(new Question("5", "10", "7", "12", 1, "How many plagues did God send on Egypt?", -1, "Exodus 7-12"));
exodus.add(new Question("Pharaoh's maid", "Pharaoh's wife", "Pharaoh's daughter", "Pharaoh's mother", 2, "Who found baby Moses in a basket along the riverside of the Nile river?", -1, "Exodus 2:3-5"));
exodus.add(new Question("Hail", "Frogs", "Boils", "Flies", 1, "What was the 2nd plague?", -1, "Exodus 8:2"));
exodus.add(new Question("Darkness for 3 days", "All water turns to blood", "Boils", "Flies", 3, "What was the 4th plague?", -1, "Exodus 8:24"));
exodus.add(new Question("Frogs", "Boils", "Hail", "Lice", 1, "What was the 6th plague?", -1, "Exodus 9:10"));
exodus.add(new Question("Boils", "All livestock dies", "Lice", "Locusts", 3, "What was the 8th plague?", -1, "Exodus 10:14"));
exodus.add(new Question("Darkness for 3 days", "Death of firstborn", "All water turns to blood", "All livestock dies", 1, "What was the 10th plague?", -1, "Exodus 12:29"));
}
代碼不是很清楚。 「公衆測驗{」實際上是指構造函數嗎? (公共測驗(){),你正在初始化該構造函數中的不同對象? – bschandramohan 2013-03-12 17:54:57
我在實際代碼的片段中添加以幫助澄清。在實際的'''Quiz''''類中,大約有500個'''Question''''對象。 – Matt 2013-03-12 17:58:51