From e513bd7e53144128faade661e6fb3199c5405ac4 Mon Sep 17 00:00:00 2001
From: Loic Guegan <16000511@e212m09.istic.univ-rennes1.fr>
Date: Tue, 1 Mar 2016 12:11:16 +0100
Subject: [PATCH] Edit grid

---
 main/Main.java      | 15 +++++----------
 structure/Grid.java | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/main/Main.java b/main/Main.java
index 64a8858..e6e6c20 100644
--- a/main/Main.java
+++ b/main/Main.java
@@ -3,19 +3,14 @@ package main;
 import org.graphstream.graph.*;
 import org.graphstream.graph.implementations.*;
 
+import structure.Grid;
+
 
 public class Main {
 
 	public static void main(String[] args) {
-		Graph graph = new SingleGraph("Tutorial 1");
-
-		graph.addNode("A");
-		graph.addNode("B");
-		graph.addNode("C");
-		graph.addEdge("AB", "A", "B");
-		graph.addEdge("BC", "B", "C");
-		graph.addEdge("CA", "C", "A");
-
-		graph.display();
+		Grid g=new Grid(5, 6,25);
+		g.displayGrid();
+	
 	}
 }
diff --git a/structure/Grid.java b/structure/Grid.java
index cdf21f4..bb3f30d 100644
--- a/structure/Grid.java
+++ b/structure/Grid.java
@@ -1,5 +1,44 @@
 package structure;
+// cedric.gueguen@irisa.fr
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Random;
+
 
 public class Grid {
 
+	private ArrayList<ArrayList<Integer>> m_grid=new ArrayList<>();
+	
+	public Grid(int size_x, int size_y, int max_rand){
+		this.generateGrid(size_x,size_y, max_rand);
+	}
+	
+	
+	
+	
+	private void generateGrid(int size_x, int size_y, int max_rand){
+		for(int x=0;x<size_x;x++){
+			m_grid.add(new ArrayList<Integer>());
+			for(int y=0;y<size_y;y++){
+				m_grid.get(x).add( (int) (Math.random() * max_rand ));
+			}
+		}
+	}
+
+	
+	public void displayGrid(){
+		Iterator<ArrayList<Integer>> i=m_grid.iterator();
+
+		while(i.hasNext()){
+			ArrayList<Integer> current=i.next();
+			Iterator<Integer> j=current.iterator();
+
+			while(j.hasNext()){
+				System.out.print(j.next() + " ");
+			}
+			System.out.println();
+		}
+	}
+	
 }