Skip to content
Snippets Groups Projects
Commit 40c4dc98 authored by marc.vachon's avatar marc.vachon
Browse files

Oh top

parent a7baee1f
Branches
No related tags found
No related merge requests found
Pipeline #4844 failed
......@@ -2,18 +2,18 @@ Projet: Meet us
Ateur: Marc Vachon
Date: 19 octobre 2018
Description:
### Description:
Application facilitant le rendez-vous de personne (minimum 2).
Avec les paramètres entré par les utilisateurs le serveur retourne
le rendez-vous le plus optimal pour le groupe de personne.
Les trajets sont calculés par rapport aux transport publique de la suisse.
Technologies:
scala,
###Technologies:
Java,
transport api,
google map
Paramètres utilisateurs:
###Paramètres utilisateurs:
durée rencontre,
jour possible,
plage horaires,
......@@ -21,7 +21,7 @@ Paramètres utilisateurs:
emplacement personne,
(prix maximum)
Recherche serveur:
###Recherche serveur:
moyenne jour possible,
moyenne heures possible,
calcul centre géographique,
......@@ -31,12 +31,12 @@ Recherche serveur:
calcul des trajets de chacun,
Trouver la bonne heure
Resultat:
###Resultat:
heure et jour du rdv,
un trajet por chacun,
(prix du trajet)
Algorithmes:
###Algorithmes:
Trouver le centre de plusieurs points:
- barycentre
- calcul de n points: x: ∑x/n y: ∑y/n
......
import java.util.*;
public class Appointment {
MyDate f_date;
ArrayList<MyDate> t_date;
public Appointment(ArrayList<MyDate> table_date) {
this.t_date = table_date;
Scanner sc = new Scanner(System.in);
System.out.println("--------------------------------------------------");
System.out.println("Durée");
System.out.println("Fini");
System.out.println("--------------------------------------------------");
System.out.println("Calcul de la date et heure idéal...");
this.most_popular_date();
System.out.println("Rendez-vous fixé le: " +
this.f_date.get_day() + "/" +
this.f_date.get_month() + "/" +
this.f_date.get_year());
System.out.println("Fini");
}
/**
* [most_popular_date description]
*/
private void most_popular_date(){
//-1 cause after dates compares hiself once
int c = 0;
int tmp = 0;
// Compare each date with each other in the table
for(MyDate date1: this.t_date){
for(MyDate date2: this.t_date){
if(compare_date(date1, date2))
c++;
}
// if date's most popular
if(c > tmp){
tmp = c;
this.f_date = date1;
}
// reset
c = -1;
}
}
private void right_period(){
for(MyDate d: this.t_date){
}
}
/**
* Compare 2 dates
* @param d1 Date format, first date
* @param d2 Date format, second date
* @return true if dates are the same
*/
private Boolean compare_date(MyDate d1, MyDate d2){
if(d1.get_day() == d2.get_day()){
if(d1.get_month() == d2.get_month()){
if(d1.get_year() == d2.get_year()){
return true;
}
}
}
return false;
}
}
import java.util.ArrayList;
import java.util.*;
public class City {
......@@ -6,10 +6,21 @@ public class City {
private String city;
private ArrayList<Location> t_loc;
private Boolean library = false;
private Boolean university = false;
public City(ArrayList<Location> table_loc) {
this.t_loc = table_loc;
Scanner sc = new Scanner(System.in);
System.out.println("--------------------------------------------------");
System.out.println("Paramètres pour le choix de la ville:");
System.out.println("Besoin d'une bibliothèque ? (y/n)");
if(sc.nextLine().equals("y"))
this.library = true;
System.out.println("Fini");
System.out.println("--------------------------------------------------");
System.out.println("Calcul du centre géogrpahique...");
this.calcul_geo_center();
......@@ -17,11 +28,11 @@ public class City {
System.out.println("Fini");
System.out.println("--------------------------------------------------");
System.out.println("Correction centre par rapport aux poids");
System.out.println("Correction centre par rapport aux poids...");
System.out.println("Fini");
System.out.println("--------------------------------------------------");
System.out.println("Choix de la ville");
System.out.println("Choix de la ville...");
System.out.println("Fini");
}
......@@ -48,8 +59,15 @@ public class City {
this.t_loc.forEach((l) -> System.out.println("x: " + l.get_x() + ", y: " + l.get_y()));
}
private void set_city_params(){
/**
* Print all city parameters state
*/
public void show_params(){
System.out.println("--------------------------------------------------");
System.out.println("Paramètres de la ville:");
System.out.println("Bibliothèque: " + this.library);
System.out.println("Université: " + this.university);
System.out.println("Fini");
}
/**
......
public class Date{
private int day;
private int month;
private int year;
public Date(int d, int m, int y){
this.day = d;
this.month = m;
this.year = y;
}
public int get_day(){
return this.day;
}
public int get_month(){
return this.month;
}
public int get_year(){
return this.year;
}
}
import java.util.ArrayList;
public class Ideal_date {
Date day_final;
ArrayList<Date> t_date;
public Ideal_date(ArrayList<Date> table_date) {
this.t_date = table_date;
}
/*
public void calcul_day(){
int d, m, y;
int[] t_d, t_m, t_y;
}
private int most_popular(int[] table){
}*/
}
/*
public final String ANSI_RESET = "\u001B[0m";
public final String ANSI_BLACK = "\u001B[30m";
public final String ANSI_RED = "\u001B[31m";
public final String ANSI_GREEN = "\u001B[32m";
public final String ANSI_YELLOW = "\u001B[33m";
public final String ANSI_BLUE = "\u001B[34m";
public final String ANSI_PURPLE = "\u001B[35m";
public final String ANSI_CYAN = "\u001B[36m";
public final String ANSI_WHITE = "\u001B[37m";
*/
import java.util.*;
import java.net.*;
import java.io.*;
import java.util.Date;
import java.text.SimpleDateFormat;
public class Meeting{
public final String ANSI_RESET = "\u001B[0m";
public final String ANSI_BLACK = "\u001B[30m";
public final String ANSI_RED = "\u001B[31m";
public final String ANSI_GREEN = "\u001B[32m";
public final String ANSI_YELLOW = "\u001B[33m";
public final String ANSI_BLUE = "\u001B[34m";
public final String ANSI_PURPLE = "\u001B[35m";
public final String ANSI_CYAN = "\u001B[36m";
public final String ANSI_WHITE = "\u001B[37m";
private static ArrayList<User> table_User;
public static void main(String[] args) {
table_User = new ArrayList<User>();
String date = "14/03/2019";
System.out.println(date_validity(date));
set_t_user();
ArrayList<MyDate> calendar = get_calendar();
print_calendar(calendar);
System.out.println("--------------------------------------------------");
System.out.println("Voici les utilisateurs entrer :");
table_User.forEach((u) -> print_user(u));
......@@ -34,20 +31,9 @@ public class Meeting{
table_User.forEach((u) -> t_loc.add(u.get_location()));
System.out.println("Fini");
/*
System.out.println("Table locations:");
t_loc.show_locs();
System.out.println();
*/
City city = new City(t_loc);
System.out.println("--------------------------------------------------");
System.out.println("Calcul de la date et heure idéal...");
System.out.println("Fini");
Appointment appointment = new Appointment(calendar);
System.out.println("--------------------------------------------------");
System.out.println("Validation des données...");
......@@ -60,16 +46,34 @@ public class Meeting{
System.out.println("--------------------------------------------------");
System.out.println("Rendus des résultats...");
System.out.println("Fini");
}
/**
* Print all user data
* @param user [description]
*/
private static void print_user(User user){
System.out.println("Utilisateur :");
System.out.println("Coordonées x, y: " + user.get_location().get_x() + ", " + user.get_location().get_y());
System.out.println("Date possible :");
user.get_calendar().forEach((d) -> System.out.println(d.get_day() + "/" + d.get_month() + "/" + d.get_year()));
System.out.println();
}
private static void init_gen_param(){
/**
* Print all date from a dates table
* @param cal ArrayList<MyDate>, array of date
*/
private static void print_calendar(ArrayList<MyDate> cal){
System.out.println("--------------------------------------------------");
System.out.println("General calendar");
cal.forEach((d) -> System.out.println(d.get_day() + "/" + d.get_month() + "/" + d.get_year()));
System.out.println("Fini");
}
/**
* Set all users with:
* their location
* their location,
* their calendar
*/
private static void set_t_user(){
......@@ -85,36 +89,56 @@ public class Meeting{
float posy = Float.parseFloat(sc.nextLine());
System.out.println("Vous avez saisi : " + posx + ", " + posy);
ArrayList<Date> t_date = set_user_date();
ArrayList<MyDate> t_date = set_date();
new_user(posx, posy, t_date);
if(table_User.size() >= 2){
System.out.println("--------------------------------------------------");
System.out.println("Avez-vous fini d'entrer les utilisateurs ? (y/n)");
if(sc.nextLine().equals("y"))
end = true;
}
}
}
/**
* Set table of date's user
* @return ArrayList of date
*/
private static ArrayList<Date> set_user_date(){
ArrayList<Date> t_date = new ArrayList<Date>();
private static ArrayList<MyDate> set_date(){
ArrayList<MyDate> t_date = new ArrayList<MyDate>();
boolean end = false;
Scanner sc = new Scanner(System.in);
while(!end){
System.out.println("Date possible (jour/mois):");
String[] date = sc.nextLine().split("/");
System.out.println("Vous avez saisi : " + date[0] + "/" + date[1] + "/2019 de " + " à ");
System.out.println("Date possible (jour/mois heure:min heure:min):");
String[] line = sc.nextLine().split(" ");
Date d = new Date(Integer.parseInt(date[0]), Integer.parseInt(date[1]), 2019);
t_date.add(d);
if(line.length == 3){
String[] date = line[0].split("/");
String[] from = line[1].split(":");
String[] to = line[2].split(":");
System.out.println("Vous avez saisi : " +
date[0] + "/" + date[1] + "/2019 de " +
from[0] + ":" + from[1] + " à " +
to[0] + ":" + to[1]);
MyDate d = new MyDate(new int[]{Integer.parseInt(date[0]), Integer.parseInt(date[1]), 2019},
new int[]{Integer.parseInt(from[0]), Integer.parseInt(from[1])},
new int[]{Integer.parseInt(to[0]), Integer.parseInt(to[1])});
t_date.add(d);
//calendar.add(d);
//
System.out.println("--------------------------------------------------");
System.out.println("Avez-vous entrer toutes les t_date ? (y/n)");
if(sc.nextLine().equals("y"))
end = true;
}else{
System.out.println("La date doit être entrée comme montré.");
}
}
return t_date;
......@@ -126,22 +150,47 @@ public class Meeting{
* @param posy [description]
* @param d [description]
*/
private static void new_user(float posx, float posy, ArrayList<Date> d){
private static void new_user(float posx, float posy, ArrayList<MyDate> d){
User u = new User(posx, posy, d);
table_User.add(u);
}
/**
* Print all user data
* @param user [description]
* Concat all user's calendar
* @return ArrayList<MyDate>, calendar of date
*/
private static void print_user(User user){
System.out.println("Utilisateur :");
System.out.println("Coordonées x, y: " + user.get_location().get_x() + ", " + user.get_location().get_y());
System.out.println("Date possible :");
user.get_calendar().forEach((d) -> System.out.println(d.get_day() + "/" + d.get_month() + "/" + d.get_year()));
System.out.println();
private static ArrayList<MyDate> get_calendar(){
ArrayList<MyDate> calendar = new ArrayList<MyDate>();
for(User u: table_User)
calendar.addAll(u.get_calendar()); // concat ArrayList
return calendar;
}
private static Boolean date_validity(String d1){
Boolean error = false;
Date d2 = new Date(); // this object contains the current date value
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
Date date = new SimpleDateFormat("dd/MM/yyyy").parse(d1);
return new Date().before(date);
}
/*
private static int[] get_current_date(){
Date currentDate = new Date(); // this object contains the current date value
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
System.out.println(formatter.format(currentDate));
String[] tmp = formatter.format(currentDate).split("-");
int[] date = {0,0,0};
for(int i = 0; i < tmp.length(); i++){
date[i] = tmp[i];
}
return date;
}*/
}
public class MyDate{
private int day;
private int month;
private int year;
private Time from;
private Time to;
public MyDate(int[] date, int[] from, int[] to){
this.day = date[0];
this.month = date[1];
this.year = date[2];
this.from = new Time(from[0], from[1]);
this.to = new Time(to[0], to[1]);
}
public int get_day(){
return this.day;
}
public int get_month(){
return this.month;
}
public int get_year(){
return this.year;
}
public int[] get_t_from(){
int[] table = {this.from.hour, this.from.minutes};
return table;
}
public int[] get_t_to(){
int[] table = {this.to.hour, this.to.minutes};
return table;
}
}
class Time{
int hour;
int minutes;
Time(int h, int m){
this.hour = h;
this.minutes = m;
}
}
......@@ -4,34 +4,55 @@ import java.io.*;
public class User {
private Location location; // location x, y
private ArrayList<Date> calendar = new ArrayList<Date>();
private ArrayList<MyDate> calendar = new ArrayList<MyDate>();
private Path path;
public User(float x, float y, ArrayList<Date> dates) {
/**
* User constructor
* @param x float, coordinate x
* @param y float, coordinate y
* @param dates ArrayList<MyDate>, table of possible dates
*/
public User(float x, float y, ArrayList<MyDate> dates) {
this.location = new Location(x, y);
this.calendar = dates;
}
/**
* Get coordinate of the user
* @return Location
*/
public Location get_location(){
return this.location;
}
/**
* Get all possible dates from the user
* @return ArrayList<MyDate>, table of dates
*/
public ArrayList<MyDate> get_calendar(){
return this.calendar;
}
/**
* Set locaton coordinate x and y
* @param x Float, Coordinate x
* @param y Float, Coordinate y
*/
public void set_location(float x, float y){
this.location.set_x(x);
this.location.set_y(y);
}
public ArrayList<Date> get_calendar(){
return this.calendar;
}
public void add_Date(int day, int month, int year){
Date d = new Date(day, month, year);
/**
* Add a Date in the calendar
* @param date int[]
* @param from int[]
* @param to int[]
*/
public void add_Date(int[] date, int[] from, int[] to){
MyDate d = new MyDate(date, from, to);
this.calendar.add(d);
}
......
JFLAGS = -g
JC = javac
JVM= java
.SUFFIXES: .java .class
.java.class:
$(JC) $(JFLAGS) $*.java
CLASSES = \
Foo.java \
Blah.java \
Library.java \
Main.java
MAIN = Meeting
default: classes
classes: $(CLASSES:.java=.class)
run: $(MAIN).class
$(JVM) $(MAIN)
clean:
$(RM) *.class
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment