無法理解如何獲取我的對象值。例如在這個代碼行中。我有對象,例如「錢」,並在按鈕單擊我想增加錢數。Java對象初始化
package com.crelix.crelix;
public class MainHolder {
int id;
String name;
int count;
public void id(int id) {
}
public MainHolder(String name) {
}
public void count(int count) {
}
public static void main(String args[]) {
MainHolder Money = new MainHolder("Money: ");
MainHolder MoneyClicks = new MainHolder("Money Clicks: ");
MainHolder Boxes = new MainHolder("Boxes: ");
MainHolder BoxClicks = new MainHolder("Boxes Clicks: ");
MainHolder BoxLevel = new MainHolder("Box Level: ");
MainHolder PlayerLevel = new MainHolder("Player Level: ");
MainHolder GarageLevel = new MainHolder("Garage Level: ");
MainHolder GarageSlots = new MainHolder("Garage Slots: ");
Money.id(1);
Money.count(0);
MoneyClicks.id(2);
MoneyClicks.count(0);
Boxes.id(3);
Boxes.count(0);
BoxClicks.id(4);
BoxClicks.count(0);
BoxLevel.id(5);
BoxLevel.count(1);
PlayerLevel.id(6);
PlayerLevel.count(1);
GarageLevel.id(7);
GarageLevel.count(1);
GarageSlots.id(8);
GarageSlots.count(25);
}
}
而我想增加例如計數值。
在我以前的代碼,我喜歡CarMain.main[0] += 1;
本守則我不能做它做它現在。
並且不能做到像CarMain.Money.count +=1;