DEV 3.2 ; TP01
This commit is contained in:
parent
8f86f3798f
commit
9bca200351
@ -101,4 +101,4 @@ public class Tableau {
|
|||||||
System.err.println("Unable to close connection.");
|
System.err.println("Unable to close connection.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
BIN
DEV 3.1/TP4/galerie/projet.jar
Normal file
BIN
DEV 3.1/TP4/galerie/projet.jar
Normal file
Binary file not shown.
BIN
DEV 3.1/TP4/galerie/res/images/house.png
Normal file
BIN
DEV 3.1/TP4/galerie/res/images/house.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
DEV 3.1/TP4/galerie/res/images/info.png
Normal file
BIN
DEV 3.1/TP4/galerie/res/images/info.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.5 KiB |
BIN
DEV 3.1/TP4/galerie/res/images/mail.png
Normal file
BIN
DEV 3.1/TP4/galerie/res/images/mail.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
DEV 3.1/TP4/galerie/res/images/ok.png
Normal file
BIN
DEV 3.1/TP4/galerie/res/images/ok.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
BIN
DEV 3.1/TP4/galerie/res/images/whatsapp.png
Normal file
BIN
DEV 3.1/TP4/galerie/res/images/whatsapp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
49
DEV 3.1/TP4/galerie/src/fr/iutfbleau/galerie/Galerie.java
Normal file
49
DEV 3.1/TP4/galerie/src/fr/iutfbleau/galerie/Galerie.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package fr.iutfbleau.galerie;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
public class Galerie {
|
||||||
|
|
||||||
|
static ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
||||||
|
private static String[] paths = {
|
||||||
|
"house", "info", "ok", "mail", "whatsapp"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static int count = -1;
|
||||||
|
private static JLabel lb;
|
||||||
|
private static JFrame window;
|
||||||
|
|
||||||
|
public static void update(boolean increment) {
|
||||||
|
count += increment ? 1 : -1;
|
||||||
|
if (count == -1) {
|
||||||
|
count = paths.length-1;
|
||||||
|
}
|
||||||
|
count %= paths.length;
|
||||||
|
|
||||||
|
if (lb != null) window.remove(lb);
|
||||||
|
|
||||||
|
try {
|
||||||
|
InputStream is = loader.getResourceAsStream("images/" + paths[count] + ".png");
|
||||||
|
lb = new JLabel(new ImageIcon(ImageIO.read(is)));
|
||||||
|
lb.addMouseListener(new GalleryListener());
|
||||||
|
window.add(lb, BorderLayout.CENTER);
|
||||||
|
window.revalidate();
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("E");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
window = new JFrame("Galerie");
|
||||||
|
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
window.setSize(650, 650);
|
||||||
|
window.setLocation(200, 200);
|
||||||
|
window.setVisible(true);
|
||||||
|
|
||||||
|
Galerie.update(true);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package fr.iutfbleau.galerie;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
|
||||||
|
public class GalleryListener implements MouseListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
JLabel source = (JLabel)e.getSource();
|
||||||
|
int x = e.getX();
|
||||||
|
|
||||||
|
Galerie.update(x > source.getWidth() / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
60
DEV 3.1/TP4/quiz/Makefile
Normal file
60
DEV 3.1/TP4/quiz/Makefile
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
JAVAC_OPTIONS = -implicit:none -d build -classpath build -sourcepath "src:tmp"
|
||||||
|
JAVA_OPTIONS = -classpath build
|
||||||
|
|
||||||
|
PROJECT_PATH = fr/iutfbleau/quiz
|
||||||
|
|
||||||
|
JAR_NAME = quiz.jar
|
||||||
|
JAR_OPTIONS = cvfe $(JAR_NAME) $(PROJECT_PATH).Startup -C build fr
|
||||||
|
|
||||||
|
jar : build/$(PROJECT_PATH)/Startup.class
|
||||||
|
jar $(JAR_OPTIONS)
|
||||||
|
|
||||||
|
exec : build/$(PROJECT_PATH)/Startup.class
|
||||||
|
java $(JAVA_OPTIONS) $(PROJECT_PATH)/Startup
|
||||||
|
|
||||||
|
rm :
|
||||||
|
rm -rf build/*
|
||||||
|
|
||||||
|
|
||||||
|
build/$(PROJECT_PATH)/Startup.class : view controller model
|
||||||
|
javac $(JAVAC_OPTIONS) src/$(PROJECT_PATH)/Startup.java
|
||||||
|
|
||||||
|
|
||||||
|
view : build/$(PROJECT_PATH)/view/ChoiceConfirm.class \
|
||||||
|
build/$(PROJECT_PATH)/view/QuestionShower.class \
|
||||||
|
build/$(PROJECT_PATH)/view/Window.class
|
||||||
|
|
||||||
|
build/$(PROJECT_PATH)/view/ChoiceConfirm.class : src/$(PROJECT_PATH)/view/ChoiceConfirm.java
|
||||||
|
javac $(JAVAC_OPTIONS) src/$(PROJECT_PATH)/view/ChoiceConfirm.java
|
||||||
|
|
||||||
|
build/$(PROJECT_PATH)/view/QuestionShower.class : src/$(PROJECT_PATH)/view/QuestionShower.java
|
||||||
|
javac $(JAVAC_OPTIONS) src/$(PROJECT_PATH)/view/QuestionShower.java
|
||||||
|
|
||||||
|
build/$(PROJECT_PATH)/view/Window.class : src/$(PROJECT_PATH)/view/Window.java
|
||||||
|
javac $(JAVAC_OPTIONS) src/$(PROJECT_PATH)/view/Window.java
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
controller : build/$(PROJECT_PATH)/controller/ChoiceValidation.class \
|
||||||
|
build/$(PROJECT_PATH)/controller/Navigation.class
|
||||||
|
|
||||||
|
build/$(PROJECT_PATH)/controller/ChoiceValidation.class : src/$(PROJECT_PATH)/controller/ChoiceValidation.java
|
||||||
|
javac $(JAVAC_OPTIONS) src/$(PROJECT_PATH)/controller/ChoiceValidation.java
|
||||||
|
|
||||||
|
build/$(PROJECT_PATH)/controller/Navigation.class : src/$(PROJECT_PATH)/controller/Navigation.java
|
||||||
|
javac $(JAVAC_OPTIONS) src/$(PROJECT_PATH)/controller/Navigation.java
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
model : build/$(PROJECT_PATH)/model/QuestionSource.class \
|
||||||
|
build/$(PROJECT_PATH)/model/Question.class \
|
||||||
|
build/$(PROJECT_PATH)/model/Choice.class
|
||||||
|
|
||||||
|
build/$(PROJECT_PATH)/model/QuestionSource.class : src/$(PROJECT_PATH)/model/QuestionSource.java
|
||||||
|
javac $(JAVAC_OPTIONS) src/$(PROJECT_PATH)/model/QuestionSource.java
|
||||||
|
|
||||||
|
build/$(PROJECT_PATH)/model/Question.class : src/$(PROJECT_PATH)/model/Question.java
|
||||||
|
javac $(JAVAC_OPTIONS) src/$(PROJECT_PATH)/model/Question.java
|
||||||
|
|
||||||
|
build/$(PROJECT_PATH)/model/Choice.class : src/$(PROJECT_PATH)/model/Choice.java
|
||||||
|
javac $(JAVAC_OPTIONS) src/$(PROJECT_PATH)/model/Choice.java
|
BIN
DEV 3.1/TP4/quiz/quiz.jar
Normal file
BIN
DEV 3.1/TP4/quiz/quiz.jar
Normal file
Binary file not shown.
12
DEV 3.1/TP4/quiz/src/fr/iutfbleau/quiz/Startup.java
Normal file
12
DEV 3.1/TP4/quiz/src/fr/iutfbleau/quiz/Startup.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package fr.iutfbleau.quiz;
|
||||||
|
|
||||||
|
import fr.iutfbleau.quiz.view.Window;
|
||||||
|
import fr.iutfbleau.quiz.controller.Navigation;
|
||||||
|
|
||||||
|
public class Startup {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Window mainWindow = new Window(100, 100, 450, 300);
|
||||||
|
mainWindow.add(new Navigation());
|
||||||
|
mainWindow.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package fr.iutfbleau.quiz.controller;
|
||||||
|
|
||||||
|
public class ChoiceValidation {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package fr.iutfbleau.quiz.controller;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class Navigation extends CardLayout implements ActionListener {
|
||||||
|
public Navigation() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
5
DEV 3.1/TP4/quiz/src/fr/iutfbleau/quiz/model/Choice.java
Normal file
5
DEV 3.1/TP4/quiz/src/fr/iutfbleau/quiz/model/Choice.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package fr.iutfbleau.quiz.model;
|
||||||
|
|
||||||
|
public class Choice {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package fr.iutfbleau.quiz.model;
|
||||||
|
|
||||||
|
public class Question {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package fr.iutfbleau.quiz.model;
|
||||||
|
|
||||||
|
public class QuestionSource {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package fr.iutfbleau.quiz.view;
|
||||||
|
|
||||||
|
public class ChoiceConfirm {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package fr.iutfbleau.quiz.view;
|
||||||
|
|
||||||
|
public class QuestionShower {
|
||||||
|
|
||||||
|
}
|
11
DEV 3.1/TP4/quiz/src/fr/iutfbleau/quiz/view/Window.java
Normal file
11
DEV 3.1/TP4/quiz/src/fr/iutfbleau/quiz/view/Window.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package fr.iutfbleau.quiz.view;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
public class Window extends JFrame {
|
||||||
|
public Window(int x, int y, int w, int h) {
|
||||||
|
super();
|
||||||
|
setLocation(x, y);
|
||||||
|
setSize(w, h);
|
||||||
|
}
|
||||||
|
}
|
31
DEV 3.2/TP01/Association/Association.java
Normal file
31
DEV 3.2/TP01/Association/Association.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
public class Association<T> {
|
||||||
|
private T element;
|
||||||
|
private int frequency;
|
||||||
|
|
||||||
|
|
||||||
|
public Association(T e, int f) {
|
||||||
|
this.element = e;
|
||||||
|
this.frequency = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setElement(T e) {
|
||||||
|
this.element = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getElement() {
|
||||||
|
return this.element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrequency(int f) {
|
||||||
|
this.frequency = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFrequency() {
|
||||||
|
return this.frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[" + this.element + ", " + this.frequency + "]";
|
||||||
|
}
|
||||||
|
}
|
34
DEV 3.2/TP01/Fréquence/Frequence.java
Normal file
34
DEV 3.2/TP01/Fréquence/Frequence.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
public class Frequence<T> {
|
||||||
|
public T mostFrequent(T[] tab) {
|
||||||
|
Hashtable<T, Integer> indexList = new Hashtable<T, Integer>();
|
||||||
|
|
||||||
|
for (T element : tab) {
|
||||||
|
indexList.put(element, indexList.get(element) == null ? 1 : ((Integer)indexList.get(element)) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
T element = tab[0];
|
||||||
|
Integer count = indexList.get(tab[0]);
|
||||||
|
|
||||||
|
for(Map.Entry<T, Integer> entry : indexList.entrySet()) {
|
||||||
|
if (entry.getValue() > count) {
|
||||||
|
element = entry.getKey();
|
||||||
|
count = entry.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Frequence<String> f = new Frequence<String>();
|
||||||
|
|
||||||
|
String[] tab = {"test", "test", "test", "12", "12", "12", "12"};
|
||||||
|
|
||||||
|
System.out.println(f.mostFrequent(tab));
|
||||||
|
}
|
||||||
|
}
|
35
DEV 3.2/TP01/Fréquences/Association.java
Normal file
35
DEV 3.2/TP01/Fréquences/Association.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
public class Association<T> {
|
||||||
|
private T element;
|
||||||
|
private int frequency;
|
||||||
|
|
||||||
|
|
||||||
|
public Association(T e, int f) {
|
||||||
|
this.element = e;
|
||||||
|
this.frequency = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setElement(T e) {
|
||||||
|
this.element = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getElement() {
|
||||||
|
return this.element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrequency(int f) {
|
||||||
|
this.frequency = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFrequency() {
|
||||||
|
return this.frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Association suivant() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[" + this.element + ", " + this.frequency + "]";
|
||||||
|
}
|
||||||
|
}
|
0
DEV 3.2/TP01/Fréquences/Frequences.java
Normal file
0
DEV 3.2/TP01/Fréquences/Frequences.java
Normal file
20
DEV 3.2/TP01/Listes/Listes.java
Normal file
20
DEV 3.2/TP01/Listes/Listes.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Listes {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ArrayList<Integer> l1 = new ArrayList<Integer>();
|
||||||
|
ArrayList<Float> l2 = new ArrayList<Float>();
|
||||||
|
ArrayList<Number> l3 = new ArrayList<Number>();
|
||||||
|
|
||||||
|
l1.add(new Integer(22));
|
||||||
|
l3.add(new Integer(32));
|
||||||
|
|
||||||
|
l2.add(new Float(52.3f));
|
||||||
|
l3.add(new Float(32.3f));
|
||||||
|
|
||||||
|
l3.add(new Long(5225922L));
|
||||||
|
|
||||||
|
l3.addAll(l1);
|
||||||
|
l3.addAll(l2);
|
||||||
|
}
|
||||||
|
}
|
10
DEV 3.2/TP01/Tableaux/Sorter.java
Normal file
10
DEV 3.2/TP01/Tableaux/Sorter.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class Sorter implements Comparator<String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(String o1, String o2) {
|
||||||
|
return o1.compareTo(o2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
10
DEV 3.2/TP01/Tableaux/Tableaux.java
Normal file
10
DEV 3.2/TP01/Tableaux/Tableaux.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class Tableaux {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String[] args2 = Arrays.copyOf(args, 5);
|
||||||
|
Arrays.sort(args2, new Sorter());
|
||||||
|
System.out.println(Arrays.toString(args2));
|
||||||
|
}
|
||||||
|
}
|
15
Fun/NewMalloc/newmem.c
Normal file
15
Fun/NewMalloc/newmem.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "newmem.h"
|
||||||
|
|
||||||
|
void* newmalloc(size_t size) {
|
||||||
|
void* start = sbrk(0);
|
||||||
|
void* finish = sbrk(size);
|
||||||
|
|
||||||
|
printf("%d\n", finish);
|
||||||
|
|
||||||
|
if (start == finish) return NULL;
|
||||||
|
return finish;
|
||||||
|
}
|
6
Fun/NewMalloc/newmem.h
Normal file
6
Fun/NewMalloc/newmem.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef NEWMEM
|
||||||
|
#define NEWMEM
|
||||||
|
|
||||||
|
void* newmalloc(size_t size);
|
||||||
|
|
||||||
|
#endif
|
9
Fun/NewMalloc/test.c
Normal file
9
Fun/NewMalloc/test.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "newmem.h"
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
char* t = (char*)newmalloc(15);
|
||||||
|
|
||||||
|
printf("%d", t != NULL);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user