Created
February 2, 2017 14:12
-
-
Save stoivo/576176b794b3ac444fab1ff61299bd2c to your computer and use it in GitHub Desktop.
regneklynge.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Regneklynge { | |
int antNode; | |
ArrayList<Rack> racks = new ArrayList<Rack>(); | |
public void setInnNode(Node node){ | |
boolean sattInn = false | |
for (int i = 0; i < racks.length-1; i++) { | |
if (racks[i].setinNode(node)) { | |
sattInn = true; | |
break; | |
} | |
} | |
if (!sattInn) { | |
Rack newRack = new Rack(this.antNode); | |
newRack.setInnNode(node); | |
racks.add(newRack); | |
} | |
} | |
} | |
public class Rack{ | |
int antNode | |
Node [] nodes = new Array[antNode]; | |
public Rack (int antNode){ | |
this.antNode = antNode; | |
Node[] nodes = New Array() | |
} | |
public boolean setinNode(Node node){ | |
for (int i = 0; i < this.antNode; i++) { | |
if (this.nodes[i] == null) { | |
this.nodes[i] = node; | |
return true; | |
} | |
} | |
return false; | |
} | |
} | |
public class Node{ | |
private Prosessor pros; | |
int antMinne; | |
int antProsesorer; | |
Node(int antKjerner, float ghz, int antMinne, int antProsesorer){ | |
this.antMinne = antMinne; | |
this.antProsesorer = antProsesorer; | |
this.pros = new Prosessor(antKjerner, ghz); | |
} | |
public int hentAntMinne(){ | |
return antMinne; | |
} | |
public int flops(){ | |
// prosessorer * antall kjerner * ghz | |
this.antProsesorer * this.pros.hentantKjerner() * this.pros.hentGhz() | |
} | |
} | |
public class Prosessor{ | |
int antKjerner; | |
float ghz; | |
public Prosessor(int antKjerner, float ghz){ | |
this.antKjerner = antKjerner; | |
this.ghz = ghz; | |
} | |
public int hentantKjerner() { | |
return antKjerner; | |
} | |
public float hentGhz(){ | |
return ghz; | |
} | |
} | |
// int cores, int ghz, float antMinne |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment