Posts tagged ‘Java’

Pseudo-Adressen generieren

Vor einiger Zeit habe ich mal ein paar Zeilen Java zusammengeschustert, um Pseudo-Adressen zu generieren. Hier der Quellcode, der weder sonderlich kompakt noch schön ist, seinen Zweck aber erfüllt:

/**
 *
 * @author Uwe Ziegenhagen, www.uweziegenhagen.de
 */
 
import java.util.*;
 
public class Addressmaker {
    static java.text.DecimalFormat format =  new java.text.DecimalFormat("00000");
    static String[] vornamen = new String[]{"Uwe","Andreas","Max","Moritz","Susi","Steffi","Janine","Tim","Tom","Marko","Hans","Thomas","Maria",
    "Bernd","Mandy","Ben","Thorsten","Sabine","Isabell","Doreen", "Nicole","Sabrina","Jenny","Klaus","Heinz","Sabrina"};
 
    static String[] nachnamen = new String[]{"Meier","Meyer","Mayer","Müller","Schulze","Lehmann",
    "Köster","Schmidt","Schuster","Wagner","Schmied","Küster","Möller"};
 
    static String[] initial = new String[]{" "," "," "," A. "," B. "," C. "," D. "," E. "," "," "};
    static String[] adressinitial = new String[]{"","a","b","c","d","","","","","",""};
    static String[] adresszusatz = new String[]{"bei Schmidt","c/o Schmidt","p.Adr. Max Mustermann"};
 
    static String[] ortsprefix = new String[]{"Wald","Wiesen","Groß","Klein","Mittel","Ober","Ham","Nieder","Alt","Alten",
    "Königs","Langen","Moos","Mühl","Morgen","Schön","Tannen","Vogel","Wolfen","Kirch","Bären","Heide","Hohen","Breiten","Ehren","Eber","Fichten","Grün"};
 
    static String[] ortssuffix = new String[]{"heim","dorf","hausen","burg","ow","au","furt","stein","aue","finow","tal","thal"};
    static String[] strassenprefix = new String[]{"Wald","Wiesen","Amsel","Drossel","Finken","Wasser","Sonnen","Schiller","Goethe","Nachtigall","Spatzen"};
    static String[] strassensuffix = new String[]{"straße","weg","gasse","allee","platz"};
    static String[] domains = new String[]{".info",".de",".com",".info",".ac.uk",".ru",".ac.jp"};
 
    static String vname = "";
    static String nname = ""; 
 
    public static void main(String[] args) {
        Random generator = new Random(new Date().getTime());
 
        int wieoft = 100;
        boolean email = true;
 
        for (int i=0;i<wieoft;i++){
            vname = vornamen[generator.nextInt(vornamen.length)];
            nname = nachnamen[generator.nextInt(nachnamen.length)];
 
        System.out.print(vname + initial[generator.nextInt(initial.length)] +  
                 nname + "\n");
 
        if (generator.nextInt(100)<3){
                    System.out.println(adresszusatz[generator.nextInt(adresszusatz.length)]);   
 
        }        
 
        System.out.print(strassenprefix[generator.nextInt(strassenprefix.length)] + 
                strassensuffix[generator.nextInt(strassensuffix.length)]+ " " + generator.nextInt(99) + adressinitial[generator.nextInt(adressinitial.length)] +  "\n");
 
        System.out.print(format.format(generator.nextInt(99999)) + " " + 
                ortsprefix[generator.nextInt(ortsprefix.length)] + 
                ortssuffix[generator.nextInt(ortssuffix.length)]+"\n");
 
        if (email==true){
            vname = vname.replaceAll("ö", "oe");
            vname = vname.replaceAll("ä", "ae");
            vname = vname.replaceAll("ü", "ue");
            nname = nname.replaceAll("ö", "oe");
            nname = nname.replaceAll("ä", "ae");
            nname = nname.replaceAll("ü", "ue");
            System.out.println(vname.toLowerCase() + "." + nname.toLowerCase() + "@" + ortssuffix[generator.nextInt(ortssuffix.length)] + domains[generator.nextInt(domains.length)]);
        }
 
        System.out.print("\n");
        }
 
    }
 
}

Uwe

Uwe Ziegenhagen mag LaTeX und Python, auch gern in Kombination. Hat Dir dieser Beitrag geholfen und möchtest Du Dich dafür bedanken? Dann unterstütze doch vielleicht die Dingfabrik Köln e.V. mit einem kleinen Beitrag. Details zur Bezahlung findest Du unter Spenden für die Dingfabrik.

More Posts - Website

Kostenlose Programmierbücher auf www.highscore.de

Auf http://www.highscore.de gibt es eine Reihe kostenloser Bücher zu verschiedenen Programmiersprachen wie C#, C++ und Java. PDF-Versionen und Lösungen der Aufgaben kosten, der eigentliche Text als HTML ist aber frei.

Uwe

Uwe Ziegenhagen mag LaTeX und Python, auch gern in Kombination. Hat Dir dieser Beitrag geholfen und möchtest Du Dich dafür bedanken? Dann unterstütze doch vielleicht die Dingfabrik Köln e.V. mit einem kleinen Beitrag. Details zur Bezahlung findest Du unter Spenden für die Dingfabrik.

More Posts - Website