I already have TOPSIS algorithm that can calculate data from an array[][]. Now I'm going to use the data from:
dummy data:
double[][] data= {
{887, 475, 4, 128, 186, 3621000},
{887, 475, 8, 128, 189, 4011000},
{1481, 991, 4, 128, 186, 4767000},
{1481, 991, 8, 128, 186, 5157000},
{1481, 991, 8, 256, 189, 5376000}};
to database's data
dao_pc.get(key).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
ArrayList<Item_pc> item_pcs = new ArrayList<>();
for (DataSnapshot data : snapshot.getChildren()) {
Item_pc item_pc = data.getValue(Item_pc.class);
item_pcs.add(item_pc);
key = data.getKey();
}
adapter_pc = new Adapter_pc(getApplicationContext(), item_pcs);
recyclerView.setAdapter(adapter_pc);
adapter_pc.notifyDataSetChanged();
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
My Item_pc.class
public class Item_pc {
private String cpu;
private String gpu;
private String ram;
private String ssd;
private String power;
private String harga;
public Item_score(String cpu, String gpu, String ram, String ssd, String power, String harga) {
this.cpu = cpu;
this.gpu = gpu;
this.ram = ram;
this.ssd = ssd;
this.power = power;
this.harga = harga;
}
public Item_pc(){}
public String getCpu() {return cpu;}
public void setCpu(String cpu) {this.cpu = cpu;}
public String getGpu() {return gpu;}
public void setGpu(String gpu) {this.gpu = gpu;}
public String getRam() {return ram;}
public void setRam(String ram) {this.ram = ram;}
public String getSsd() {return ssd;}
public void setSsd(String ssd) {this.ssd = ssd;}
public String getPower() {return power;}
public void setPower(String power) {this.power = power;}
public String getHarga() {return harga;}
public void setHarga(String harga) {this.harga = harga;}
Condition:
- I can get data from firebase using arraylist
- I can calculate data using dummy array with TOPSIS algorithm
problem : how to calculate data from firebase with TOPSIS algorithm? I have trouble that data from firebase need to use Arraylist format, I don't know how to store data on array[][] like array_push(PHP version) on java android.
Item_scoreclass.Integerand then you addItem_scoreobjects to it; doesItem_scoreextendInteger? Seems unlikely. And then you want to cast theintvalues withinItem_scoretodouble; why?Item_pcclass has 12 fields but you only want an array with 6 fields.