commit
82dbd9c10d
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="weihnatchswichtelMaven" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="TOP_LEVEL_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="INNER_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="METHOD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="FIELD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="IGNORE_DEPRECATED" value="false" />
|
||||||
|
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
|
||||||
|
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
|
||||||
|
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
|
||||||
|
<option name="myAdditionalJavadocTags" value="info" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.example</groupId>
|
||||||
|
<artifactId>weihnatchswichtelMaven</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.mail</groupId>
|
||||||
|
<artifactId>javax.mail</artifactId>
|
||||||
|
<version>1.6.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String[] people = new String[10];
|
||||||
|
String[] mails = new String[10];
|
||||||
|
people[0] = "Lukas 0";
|
||||||
|
people[1] = "Jan 0";
|
||||||
|
people[2] = "Ulrike 0";
|
||||||
|
people[3] = "Petra 1";
|
||||||
|
people[4] = "Dietmar 1";
|
||||||
|
people[5] = "Lisa 1";
|
||||||
|
people[6] = "Andreas 1";
|
||||||
|
people[7] = "Annette 2";
|
||||||
|
people[8] = "Julia 2";
|
||||||
|
people[9] = "Mark 2";
|
||||||
|
|
||||||
|
// mails[0] = "contact@lukasmartin.eu";
|
||||||
|
// mails[1] = "janmartin2@hotmail.de";
|
||||||
|
// mails[2] = "monsterfamilie@gmx.de";
|
||||||
|
// mails[3] = "petra.scheib@t-online.de";
|
||||||
|
// mails[4] = "d-scheib@gmx.de";
|
||||||
|
// mails[5] = "lisa.scheib92@gmx.de";
|
||||||
|
// mails[6] = "andreas_goll@t-online.de";
|
||||||
|
// mails[7] = "Annette-simon@t-online.de";
|
||||||
|
// mails[8] = "Julia-Marie-simon@gmx.de";
|
||||||
|
// mails[9] = "Marcschwarz77@gmail.com";
|
||||||
|
|
||||||
|
|
||||||
|
RandomMatch rm = new RandomMatch();
|
||||||
|
SendMail sm = new SendMail();
|
||||||
|
String[][] test = rm.match(people);
|
||||||
|
// for (String[] strings : test) {
|
||||||
|
// System.out.println(strings[0].substring(0, strings[0].length() - 1) + ": " + strings[1].substring(0, strings[1].length() - 1));
|
||||||
|
// }
|
||||||
|
sm.sendMail(test, mails);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class RandomMatch {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Lukas Martin
|
||||||
|
* @param people {@code String}
|
||||||
|
* @info Assigns every person in {@param people} a correct counter part.
|
||||||
|
*/
|
||||||
|
public String[][] match(String[] people) {
|
||||||
|
Random random = new Random();
|
||||||
|
int j = 0;
|
||||||
|
String[][] matches = new String[people.length][people.length];
|
||||||
|
for(int i = 0; i < matches.length; i++) {
|
||||||
|
matches[i][0] = ""; matches[i][1] = "";
|
||||||
|
}
|
||||||
|
for(int i = 0; i < people.length; i++) {
|
||||||
|
int rand = random.nextInt(10);
|
||||||
|
if(j > 10000) {
|
||||||
|
for(int k = 0; k < matches.length; k++) {
|
||||||
|
matches[k][0] = ""; matches[k][1] = "";
|
||||||
|
i = 0; j = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(checkRelation(people[i], people[rand]) || isAlreadyDrawn(matches, people[rand])) {
|
||||||
|
i = i - 1; j = j +1;
|
||||||
|
} else {
|
||||||
|
matches[i][0] = people[i]; matches[i][1] = people[rand];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matches;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Lukas Martin
|
||||||
|
* @param person0 {@code String}
|
||||||
|
* @param person1 {@code String}
|
||||||
|
* @return {@code true} if the two given people are related.
|
||||||
|
*/
|
||||||
|
private Boolean checkRelation(String person0, String person1) {
|
||||||
|
return person0.substring(person0.length() - 1).equals(person1.substring(person1.length() - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Lukas Martin
|
||||||
|
* @param matches {@code String[][]}
|
||||||
|
* @param person {@code String}
|
||||||
|
* @return {@code true} if person is already drawn.
|
||||||
|
*/
|
||||||
|
private Boolean isAlreadyDrawn(String[][] matches, String person) {
|
||||||
|
for (String[] match : matches) {
|
||||||
|
if (match[1].equals(person)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
import javax.mail.*;
|
||||||
|
import javax.mail.internet.InternetAddress;
|
||||||
|
import javax.mail.internet.MimeMessage;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class SendMail {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Lukas Martin
|
||||||
|
* @param matches {@code String[][]}
|
||||||
|
* @param mails {@code String[]}
|
||||||
|
* @info Uses the params to send mails to the chosen people.
|
||||||
|
*/
|
||||||
|
public void sendMail(String[][] matches, String[] mails) {
|
||||||
|
//authentication info
|
||||||
|
final String username = "weihnachtswichteln0@gmail.com";
|
||||||
|
final String password = "fmrvjhogruskvjkj\n";
|
||||||
|
String fromEmail = "weihnachtswichteln0@gmail.com";
|
||||||
|
String toEmail = "lukas.martin155@outlook.de";
|
||||||
|
|
||||||
|
Properties properties = new Properties();
|
||||||
|
properties.put("mail.smtp.auth", "true");
|
||||||
|
properties.put("mail.smtp.starttls.enable", "true");
|
||||||
|
properties.put("mail.smtp.host", "smtp.gmail.com");
|
||||||
|
properties.put("mail.smtp.port", "587");
|
||||||
|
properties.put("mail.smtp.ssl.trust", "smtp.gmail.com");
|
||||||
|
|
||||||
|
Session session = Session.getInstance(properties, new javax.mail.Authenticator() {
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(username, password);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//Start our mail message
|
||||||
|
for(int i = 0; i < matches.length; i++) {
|
||||||
|
MimeMessage msg = new MimeMessage(session);
|
||||||
|
try {
|
||||||
|
msg.setFrom(new InternetAddress(fromEmail));
|
||||||
|
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(mails[i]));
|
||||||
|
msg.setSubject("Weihnachtswichteln 2023");
|
||||||
|
msg.setText("Hallo liebe/r " + matches[i][0].substring(0, matches[i][0].length() - 2)+ "," + "\n" +
|
||||||
|
"\n" +
|
||||||
|
"Dein Match für das diesjährige Wichteln ist " + matches[i][1].substring(0, matches[i][1].length() - 2) + "." + "\n" +
|
||||||
|
"\n" +
|
||||||
|
"Mit freundlichen Grüßen \n" +
|
||||||
|
"Dein Wichtelsystem" + "\n" +
|
||||||
|
"\n" + "\n" +
|
||||||
|
|
||||||
|
"--Bitte beachtet, dass ungefähr für 25€ gewichtelt wird--");
|
||||||
|
Transport.send(msg);
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
amount: 10
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
amount: 10
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
#Generated by Maven
|
||||||
|
#Wed Nov 10 19:44:59 CET 2021
|
||||||
|
groupId=org.example
|
||||||
|
artifactId=weihnatchswichtelMaven
|
||||||
|
version=1.0-SNAPSHOT
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
F:\1_java\weihnatchswichtelMaven\src\main\java\SendMail.java
|
||||||
|
F:\1_java\weihnatchswichtelMaven\src\main\java\Main.java
|
||||||
|
F:\1_java\weihnatchswichtelMaven\src\main\java\RandomMatch.java
|
||||||
Binary file not shown.
Loading…
Reference in new issue