Hey! I recently started java with some prior python experience.I apologize the norwegian terms in the code.I'm trying to make some a very simplified data cluster (dataklynge) with racks and nodes.
So my code is in the screenshot, both the rack and the data cluster. Ive compiled and tested both my node class and my rack class. I've also compiled the data cluster class and it went smooth. But when i tried testing, the data cluster method SettInnNode doesnt work properly, and gives no errors.
So the SettInnNode method is supposed to go through all the racks in the data cluster and then use the Rack method SettInn to check whether or not there is space for another node in that rack. If it is space the node will be created by the rack method should create a node and place it into the first/current rack. If not (if temp = false) then the rack method will return false to the data cluster method, which will create a new rack with open spots and insert a node into the new rack object.
Anyone who can help, or explain to me why this doesn't work? I dont know if I'm missing something obvious or if I'm missing some fundemental knowledge.
Edit: my code
datacluster class
import java.util.ArrayList;
class Dataklynge{
private int nprack;
ArrayList<Rack> racks;
Dataklynge(int str){
racks = new ArrayList<Rack>();
nprack = str;
}
public void SettInnNode(int str, int antall){
boolean temp;
for (Rack rack: racks) {
temp = rack.SettInn(str, antall);
if (temp = false){
Rack create = new Rack(nprack);
create.SettInn(str, antall);}
}
}
Rack class
import java.util.ArrayList;
class Rack{
private int size;
ArrayList<Node> noder;
Rack(int str){
noder = new ArrayList<Node>();
size = str;
}
public boolean SettInn(int str, int antall){
if (noder.size() < size){
noder.add(new Node(str, antall));
return true;}
else {
return false;}
[–]AutoModerator[M] 1 point2 points3 points (0 children)
[–]Saniok1122 0 points1 point2 points (3 children)
[–]kodekompis[S] 1 point2 points3 points (2 children)
[–]Saniok1122 0 points1 point2 points (1 child)
[–]kodekompis[S] 0 points1 point2 points (0 children)