Update
This commit is contained in:
parent
ca5a8516fd
commit
43627048d8
@ -76,29 +76,11 @@ public class Flocon extends Polygon {
|
||||
f.setSize(1200, 1200);
|
||||
|
||||
Flocon p = new Flocon();
|
||||
p.createFloc(f.getWidth() / 2, f.getHeight() / 2 - 100, 500, 4, 0);
|
||||
p.createFloc(f.getWidth() / 2, f.getHeight() / 2 - 100, 500, Integer.parseInt(args[0]), 0);
|
||||
|
||||
FloconPanel fp = new FloconPanel(p);
|
||||
|
||||
f.add(fp);
|
||||
|
||||
f.setVisible(true);
|
||||
|
||||
int a = 0;
|
||||
while(true) {
|
||||
try {
|
||||
Thread.sleep(16);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
a += 1;
|
||||
|
||||
p.xpoints = new int[0];
|
||||
p.ypoints = new int[0];
|
||||
p.npoints = 0;
|
||||
p.createFloc(f.getWidth() / 2, f.getHeight() / 2 - 100, 500, 4, a);
|
||||
fp.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
DEV 3.2/TP05/Fusion/DoubleSorter.java
Normal file
11
DEV 3.2/TP05/Fusion/DoubleSorter.java
Normal file
@ -0,0 +1,11 @@
|
||||
import java.util.Comparator;
|
||||
|
||||
public class DoubleSorter implements Comparator<Double> {
|
||||
|
||||
@Override
|
||||
public int compare(Double o1, Double o2) {
|
||||
if (o1 > o2) return 1;
|
||||
else if (o1 == o2) return 0;
|
||||
else return -1;
|
||||
}
|
||||
}
|
44
DEV 3.2/TP05/Fusion/Fusion.java
Normal file
44
DEV 3.2/TP05/Fusion/Fusion.java
Normal file
@ -0,0 +1,44 @@
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class Fusion<T> {
|
||||
|
||||
private Comparator<T> s;
|
||||
|
||||
public Fusion(Comparator<T> s) {
|
||||
this.s = s;
|
||||
}
|
||||
|
||||
public void scinder(ArrayDeque<T> first, ArrayDeque<T> second) {
|
||||
second.clear();
|
||||
|
||||
int count = first.size() / 2;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
second.addFirst(first.pollLast());
|
||||
}
|
||||
}
|
||||
|
||||
public void fusionner(ArrayDeque<T> first, ArrayDeque<T> second) {
|
||||
for (T e : second) {
|
||||
first.addFirst(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void trier(ArrayDeque<T> d) {
|
||||
switch (d.size()) {
|
||||
case 2:
|
||||
if (s.compare(d.getFirst(), d.getLast()) < 0) {
|
||||
d.addFirst(d.pollLast());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ArrayDeque<T> second = new ArrayDeque<>();
|
||||
scinder(d, second);
|
||||
|
||||
trier(d);
|
||||
trier(second);
|
||||
fusionner(d, second);
|
||||
}
|
||||
}
|
||||
}
|
29
DEV 3.2/TP05/Fusion/Main.java
Normal file
29
DEV 3.2/TP05/Fusion/Main.java
Normal file
@ -0,0 +1,29 @@
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fusion<Double> f = new Fusion<Double>(new Comparator<Double>() {
|
||||
|
||||
@Override
|
||||
public int compare(Double o1, Double o2) {
|
||||
if (o1 > o2) return 1;
|
||||
else if (o1 == o2) return 0;
|
||||
else return -1;
|
||||
}
|
||||
});
|
||||
|
||||
ArrayDeque<Double> list = new ArrayDeque<>();
|
||||
|
||||
for (String arg : args) {
|
||||
try {
|
||||
double d = Double.parseDouble(arg);
|
||||
list.addFirst(d);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Invalid arg : " + arg);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(list.toString());
|
||||
}
|
||||
}
|
4
DEV 3.2/TP05/Fusion/Sorter.java
Normal file
4
DEV 3.2/TP05/Fusion/Sorter.java
Normal file
@ -0,0 +1,4 @@
|
||||
public interface Sorter<T> {
|
||||
|
||||
public boolean isFirstSecond(T a, T b);
|
||||
}
|
32
DEV 3.2/TP05/Serpent/Cell.java
Normal file
32
DEV 3.2/TP05/Serpent/Cell.java
Normal file
@ -0,0 +1,32 @@
|
||||
import javax.swing.JPanel;
|
||||
import java.awt.*;
|
||||
|
||||
|
||||
public class Cell extends JPanel {
|
||||
private CellType type;
|
||||
|
||||
private static final int offset = 2;
|
||||
private static final int arc = 5;
|
||||
|
||||
public Cell() {
|
||||
super();
|
||||
setOpaque(false);
|
||||
type = CellType.EMPTY;
|
||||
}
|
||||
|
||||
public CellType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(CellType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
protected void paintComponent(Graphics g) {
|
||||
Graphics ng = g.create();
|
||||
((Graphics2D)ng).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
ng.setColor(type.getColor());
|
||||
ng.fillRoundRect(offset, offset, getWidth() - offset * 2, getHeight() - offset * 2, arc, arc);
|
||||
}
|
||||
}
|
18
DEV 3.2/TP05/Serpent/CellType.java
Normal file
18
DEV 3.2/TP05/Serpent/CellType.java
Normal file
@ -0,0 +1,18 @@
|
||||
import java.awt.Color;
|
||||
|
||||
public enum CellType {
|
||||
SNAKE(Color.ORANGE),
|
||||
EMPTY(Color.GREEN),
|
||||
FRUIT(Color.RED),
|
||||
VOID(Color.BLACK);
|
||||
|
||||
private Color c;
|
||||
|
||||
private CellType(Color c) {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return c;
|
||||
}
|
||||
}
|
33
DEV 3.2/TP05/Serpent/GameOverTask.java
Normal file
33
DEV 3.2/TP05/Serpent/GameOverTask.java
Normal file
@ -0,0 +1,33 @@
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class GameOverTask extends TimerTask {
|
||||
|
||||
private Timer parent;
|
||||
private SnakePanel game;
|
||||
private int i;
|
||||
|
||||
public GameOverTask(SnakePanel game, Timer parent) {
|
||||
this.game = game;
|
||||
this.parent = parent;
|
||||
i = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (int x = i; x >= 0; x--) {
|
||||
int y = i - x;
|
||||
if (x < game.sizeX && y < game.sizeY) {
|
||||
game.getGrid()[x][y].setType(CellType.VOID);
|
||||
|
||||
if (x == game.sizeX - 1 && y == game.sizeY - 1) {
|
||||
parent.cancel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
game.repaint();
|
||||
}
|
||||
}
|
15
DEV 3.2/TP05/Serpent/Main.java
Normal file
15
DEV 3.2/TP05/Serpent/Main.java
Normal file
@ -0,0 +1,15 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
JFrame masterFrame = new JFrame("Snake");
|
||||
masterFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
masterFrame.setLocation(100, 100);
|
||||
masterFrame.setSize(500, 500);
|
||||
masterFrame.add(new SnakePanel());
|
||||
masterFrame.setVisible(true);
|
||||
}
|
||||
}
|
79
DEV 3.2/TP05/Serpent/Snake.java
Normal file
79
DEV 3.2/TP05/Serpent/Snake.java
Normal file
@ -0,0 +1,79 @@
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class Snake {
|
||||
|
||||
private int headX;
|
||||
private int headY;
|
||||
|
||||
private Cell[][] grid;
|
||||
|
||||
LinkedList<Cell> snakeCells;
|
||||
|
||||
private int length;
|
||||
private SnakePanel parent;
|
||||
private int direction = KeyEvent.VK_RIGHT;
|
||||
|
||||
public Snake(SnakePanel parent) {
|
||||
this.parent = parent;
|
||||
this.grid = parent.getGrid();
|
||||
|
||||
length = 3;
|
||||
headX = parent.sizeX / 2;
|
||||
headY = parent.sizeY / 2;
|
||||
|
||||
snakeCells = new LinkedList<Cell>();
|
||||
|
||||
grid[headY][headX].setType(CellType.SNAKE);
|
||||
snakeCells.addFirst(grid[headX][headY]);
|
||||
}
|
||||
|
||||
public int getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(int direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public void performMove() {
|
||||
switch (direction) {
|
||||
case (KeyEvent.VK_RIGHT):
|
||||
headX++;
|
||||
break;
|
||||
|
||||
case (KeyEvent.VK_LEFT):
|
||||
headX--;
|
||||
break;
|
||||
|
||||
case (KeyEvent.VK_UP):
|
||||
headY--;
|
||||
break;
|
||||
|
||||
case (KeyEvent.VK_DOWN):
|
||||
headY++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (headY >= parent.sizeY || headX >= parent.sizeX) {
|
||||
parent.gameOver();
|
||||
return;
|
||||
}
|
||||
Cell newCell = grid[headY][headX];
|
||||
|
||||
if (newCell == null || newCell.getType() == CellType.SNAKE) {
|
||||
parent.gameOver();
|
||||
return;
|
||||
}
|
||||
|
||||
snakeCells.addFirst(newCell);
|
||||
newCell.setType(CellType.SNAKE);
|
||||
newCell.repaint();
|
||||
|
||||
if (snakeCells.size() > length) {
|
||||
Cell c = snakeCells.removeLast();
|
||||
c.setType(CellType.EMPTY);
|
||||
c.repaint();
|
||||
}
|
||||
}
|
||||
}
|
49
DEV 3.2/TP05/Serpent/SnakeListener.java
Normal file
49
DEV 3.2/TP05/Serpent/SnakeListener.java
Normal file
@ -0,0 +1,49 @@
|
||||
import java.awt.event.*;
|
||||
|
||||
public class SnakeListener implements KeyListener {
|
||||
|
||||
private SnakePanel parent;
|
||||
|
||||
public SnakeListener(SnakePanel parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
Snake s = parent.getSnake();
|
||||
|
||||
switch (e.getKeyCode()) {
|
||||
case (KeyEvent.VK_LEFT):
|
||||
s.setDirection(KeyEvent.VK_LEFT);
|
||||
break;
|
||||
|
||||
case (KeyEvent.VK_RIGHT):
|
||||
s.setDirection(KeyEvent.VK_RIGHT);
|
||||
break;
|
||||
|
||||
case (KeyEvent.VK_UP):
|
||||
s.setDirection(KeyEvent.VK_UP);
|
||||
break;
|
||||
|
||||
case (KeyEvent.VK_DOWN):
|
||||
s.setDirection(KeyEvent.VK_DOWN);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
58
DEV 3.2/TP05/Serpent/SnakePanel.java
Normal file
58
DEV 3.2/TP05/Serpent/SnakePanel.java
Normal file
@ -0,0 +1,58 @@
|
||||
import javax.swing.JPanel;
|
||||
import java.awt.*;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class SnakePanel extends JPanel {
|
||||
|
||||
private Cell[][] grid;
|
||||
private Timer moveTimer;
|
||||
private Snake snake;
|
||||
|
||||
public final int sizeX = 25;
|
||||
public final int sizeY = 25;
|
||||
|
||||
|
||||
public SnakePanel() {
|
||||
super();
|
||||
grid = new Cell[sizeX][sizeY];
|
||||
|
||||
setLayout(new GridLayout(sizeY, sizeX));
|
||||
|
||||
for (int x = 0; x < sizeX; x++) {
|
||||
for (int y = 0; y < sizeY; y++) {
|
||||
grid[x][y] = new Cell();
|
||||
add(grid[x][y]);
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
this.snake = new Snake(this);
|
||||
addKeyListener(new SnakeListener(this));
|
||||
|
||||
moveTimer = new Timer();
|
||||
moveTimer.scheduleAtFixedRate(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
requestFocus();
|
||||
snake.performMove();
|
||||
}
|
||||
|
||||
}, 200, 200);
|
||||
}
|
||||
|
||||
public void gameOver() {
|
||||
moveTimer.cancel();
|
||||
|
||||
Timer gameOverTimer = new Timer();
|
||||
gameOverTimer.scheduleAtFixedRate(new GameOverTask(this, gameOverTimer), 0, 60);
|
||||
}
|
||||
|
||||
public Cell[][] getGrid() {
|
||||
return grid;
|
||||
}
|
||||
|
||||
public Snake getSnake() {
|
||||
return snake;
|
||||
}
|
||||
}
|
33
DEV 3.2/TP06/Compteur/Compteur.java
Normal file
33
DEV 3.2/TP06/Compteur/Compteur.java
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Compteur {
|
||||
public static void main(String[] args) {
|
||||
Map<String, Integer> list = new HashMap<>();
|
||||
|
||||
while (true) {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
try {
|
||||
String saisie = br.readLine();
|
||||
System.out.print(saisie);
|
||||
if (saisie == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (list.containsKey(saisie)) {
|
||||
list.put(saisie, list.get(saisie) + 1);
|
||||
} else {
|
||||
list.put(saisie, 1);
|
||||
}
|
||||
|
||||
System.out.println(list.get(saisie));
|
||||
} catch (Exception ioe) {
|
||||
System.out.println(ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
61
DEV 3.2/TP06/Couleurs/Couleurs.java
Normal file
61
DEV 3.2/TP06/Couleurs/Couleurs.java
Normal file
@ -0,0 +1,61 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.awt.event.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.StringReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
public class Couleurs {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Map<String, Color> colorDict = new HashMap<String,Color>();
|
||||
|
||||
try (BufferedReader fs = new BufferedReader(new FileReader("rgb.txt"))) {
|
||||
|
||||
String line;
|
||||
while ((line = fs.readLine()) != null) {
|
||||
String[] elements = line.trim().split("[\\s\t]+");
|
||||
|
||||
Color c = new Color(Integer.parseInt(elements[0]), Integer.parseInt(elements[1]), Integer.parseInt(elements[2]));
|
||||
String name = elements[3];
|
||||
colorDict.put(name, c);
|
||||
}
|
||||
} catch (Exception e ) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
JFrame f = new JFrame();
|
||||
f.setLayout(new GridLayout(1, 2));
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.setSize(400, 250);
|
||||
|
||||
String[] nameArray = new String[colorDict.size()];
|
||||
colorDict.keySet().toArray(nameArray);
|
||||
|
||||
JList<String> list = new JList<String>(nameArray);
|
||||
JScrollPane jpane = new JScrollPane(list);
|
||||
jpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
f.add(jpane);
|
||||
|
||||
JPanel p = new JPanel();
|
||||
f.add(p);
|
||||
|
||||
list.addListSelectionListener(new ListSelectionListener() {
|
||||
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
p.setBackground(colorDict.get(list.getSelectedValue()));
|
||||
}
|
||||
|
||||
});
|
||||
f.setVisible(true);
|
||||
}
|
||||
}
|
752
DEV 3.2/TP06/Couleurs/rgb.txt
Normal file
752
DEV 3.2/TP06/Couleurs/rgb.txt
Normal file
File diff suppressed because it is too large
Load Diff
54
DEV 3.2/TP06/Hachage/Couleurs.java
Normal file
54
DEV 3.2/TP06/Hachage/Couleurs.java
Normal file
@ -0,0 +1,54 @@
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.util.Map;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
public class Couleurs {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Map<String, Color> colorDict = new Hachage<String,Color>();
|
||||
|
||||
try (BufferedReader fs = new BufferedReader(new FileReader("rgb.txt"))) {
|
||||
|
||||
String line;
|
||||
while ((line = fs.readLine()) != null) {
|
||||
String[] elements = line.trim().split("[\\s\t]+");
|
||||
|
||||
Color c = new Color(Integer.parseInt(elements[0]), Integer.parseInt(elements[1]), Integer.parseInt(elements[2]));
|
||||
String name = elements[3];
|
||||
colorDict.put(name, c);
|
||||
}
|
||||
} catch (Exception e ) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
JFrame f = new JFrame();
|
||||
f.setLayout(new GridLayout(1, 2));
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.setSize(400, 250);
|
||||
|
||||
String[] nameArray = new String[colorDict.size()];
|
||||
colorDict.keySet().toArray(nameArray);
|
||||
|
||||
JList<String> list = new JList<String>(nameArray);
|
||||
JScrollPane jpane = new JScrollPane(list);
|
||||
jpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
f.add(jpane);
|
||||
|
||||
JPanel p = new JPanel();
|
||||
f.add(p);
|
||||
|
||||
list.addListSelectionListener(new ListSelectionListener() {
|
||||
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
p.setBackground(colorDict.get(list.getSelectedValue()));
|
||||
}
|
||||
|
||||
});
|
||||
f.setVisible(true);
|
||||
}
|
||||
}
|
29
DEV 3.2/TP06/Hachage/Entree.java
Normal file
29
DEV 3.2/TP06/Hachage/Entree.java
Normal file
@ -0,0 +1,29 @@
|
||||
import java.util.Map;
|
||||
|
||||
public class Entree<K, V> implements Map.Entry<K, V> {
|
||||
|
||||
private K key;
|
||||
private V value;
|
||||
|
||||
public Entree(K key, V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public K getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V setValue(V value) {
|
||||
this.value = value;
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
102
DEV 3.2/TP06/Hachage/Hachage.java
Normal file
102
DEV 3.2/TP06/Hachage/Hachage.java
Normal file
@ -0,0 +1,102 @@
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class Hachage<K, V> implements Map<K, V> {
|
||||
|
||||
LinkedList<Map.Entry<K, V>> list;
|
||||
|
||||
public Hachage() {
|
||||
list = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
list.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Entry<K, V>> entrySet() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(Object key) {
|
||||
for (Map.Entry<K, V> entry : list) {
|
||||
if (key.equals(entry.getKey())) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
Set<K> set = new HashSet<>(list.size());
|
||||
|
||||
for (Entry<K, V> entry : list) {
|
||||
set.add(entry.getKey());
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
for (Map.Entry<K, V> entry : list) {
|
||||
if (key.equals(entry.getKey())) {
|
||||
V oldValue = entry.getValue();
|
||||
entry.setValue(value);
|
||||
return oldValue;
|
||||
}
|
||||
}
|
||||
|
||||
list.add(new Entree<K, V>(key ,value));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> m) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
752
DEV 3.2/TP06/Hachage/rgb.txt
Normal file
752
DEV 3.2/TP06/Hachage/rgb.txt
Normal file
File diff suppressed because it is too large
Load Diff
21
DEV 3.2/TP06/Traces/Traces.java
Normal file
21
DEV 3.2/TP06/Traces/Traces.java
Normal file
@ -0,0 +1,21 @@
|
||||
package Traces;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Traces
|
||||
*/
|
||||
public class Traces {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Map<Thread, StackTraceElement[]> dict = Thread.getAllStackTraces();
|
||||
|
||||
for (Map.Entry<Thread, StackTraceElement[]> entry : dict.entrySet()) {
|
||||
System.out.println(entry.getKey().getName());
|
||||
|
||||
for (StackTraceElement el : entry.getValue()) {
|
||||
System.out.println("\t" + el.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3710
DEV 3.4/TD3/Livre.mdj
Normal file
3710
DEV 3.4/TD3/Livre.mdj
Normal file
File diff suppressed because it is too large
Load Diff
5583
DEV 3.4/TD3/MMOG.mdj
Normal file
5583
DEV 3.4/TD3/MMOG.mdj
Normal file
File diff suppressed because it is too large
Load Diff
2917
DEV 3.4/TD3/Shape.mdj
Normal file
2917
DEV 3.4/TD3/Shape.mdj
Normal file
File diff suppressed because it is too large
Load Diff
3238
DEV 3.4/TD3/rugby.mdj
Normal file
3238
DEV 3.4/TD3/rugby.mdj
Normal file
File diff suppressed because it is too large
Load Diff
1
DEV 3.4/TD3/réponses.txt
Normal file
1
DEV 3.4/TD3/réponses.txt
Normal file
@ -0,0 +1 @@
|
||||
Ex1: Factory
|
4160
DEV 3.4/TD4/DC.mdj
Normal file
4160
DEV 3.4/TD4/DC.mdj
Normal file
File diff suppressed because it is too large
Load Diff
23
DEV 3.4/TD4/DNAIterator.java
Normal file
23
DEV 3.4/TD4/DNAIterator.java
Normal file
@ -0,0 +1,23 @@
|
||||
import java.util.Iterator;
|
||||
|
||||
public class DNAIterator implements Iterator<DNALetter> {
|
||||
|
||||
private DNASequence first;
|
||||
|
||||
public DNAIterator(DNASequence first) {
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return first != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DNALetter next() {
|
||||
DNALetter curr = first.getValue();
|
||||
first = first.getNext();
|
||||
return curr;
|
||||
}
|
||||
|
||||
}
|
16
DEV 3.4/TD4/DNALetter.java
Normal file
16
DEV 3.4/TD4/DNALetter.java
Normal file
@ -0,0 +1,16 @@
|
||||
public enum DNALetter {
|
||||
A("A"),
|
||||
C("C"),
|
||||
G("G"),
|
||||
T("T");
|
||||
|
||||
private String value;
|
||||
|
||||
private DNALetter(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
21
DEV 3.4/TD4/DNASequence.java
Normal file
21
DEV 3.4/TD4/DNASequence.java
Normal file
@ -0,0 +1,21 @@
|
||||
public class DNASequence {
|
||||
|
||||
private DNALetter value;
|
||||
private DNASequence next;
|
||||
|
||||
public DNASequence(DNALetter value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public DNALetter getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public DNASequence getNext() {
|
||||
return next;
|
||||
}
|
||||
|
||||
public void setNext(DNASequence next) {
|
||||
this.next = next;
|
||||
}
|
||||
}
|
32
DEV 3.4/TD4/DNAStrand.java
Normal file
32
DEV 3.4/TD4/DNAStrand.java
Normal file
@ -0,0 +1,32 @@
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* DNAStrand
|
||||
*/
|
||||
public class DNAStrand implements Iterable {
|
||||
|
||||
private DNASequence sequence;
|
||||
private DNASequence last;
|
||||
|
||||
public DNAStrand() {
|
||||
|
||||
}
|
||||
|
||||
public void addLast(DNALetter letter) {
|
||||
if (sequence != null) {
|
||||
last.setNext(new DNASequence(letter));
|
||||
last = last.getNext();
|
||||
} else {
|
||||
sequence = new DNASequence(letter);
|
||||
last = sequence;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterator<DNALetter> iterator() {
|
||||
return (new DNAIterator(sequence));
|
||||
}
|
||||
|
||||
|
||||
}
|
18
DEV 3.4/TD4/Test.java
Normal file
18
DEV 3.4/TD4/Test.java
Normal file
@ -0,0 +1,18 @@
|
||||
import java.util.Iterator;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
DNAStrand s = new DNAStrand();
|
||||
|
||||
s.addLast(DNALetter.A);
|
||||
s.addLast(DNALetter.C);
|
||||
s.addLast(DNALetter.G);
|
||||
s.addLast(DNALetter.T);
|
||||
|
||||
|
||||
Iterator<DNALetter> i = s.iterator();
|
||||
while (i.hasNext()) {
|
||||
System.out.println(i.next().getValue());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user