Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- public class LagerProgramm {
- public static void main(String[] args) {
- //This stuff will come out of the excel file afterwards
- Object[][] int_workshops = {
- { "Springen", 4, 8 }, // min=4, max=8
- { "Tanzen", 2, 10},
- { "Lesen", 2, 10},
- { "Klettern", 5, 10},
- { "Fussball", 2, 10},
- { "Theater", 2, 10},
- { "Schwingen", 2, 10}
- };
- //This stuff will come out of the excel file afterwards, part=participant
- int[][] int_teilnehmer = {
- /* part1 */ { 0,1,2}, //prio1=worshop[0]="Springen", prio2="Tanzen", prio3="Lesen"
- /* part2 */ { 0,1,2},
- { 5,1,2}, //prio1="Theater", ...
- { 0,1,2},
- { 5,4,2},
- { 4,6,2},
- { 3,1,2},
- { 2,1,3},
- { 5,1,6},
- { 1,2,5},
- { 2,3,4},
- { 2,6,3},
- { 4,1,2},
- { 3,1,4},
- };
- //make an Array of Workshops
- Workshop[] workshops = new Workshop[ int_workshops.length ];
- for(int i=0; i<workshops.length; i++){
- workshops[i] = new Workshop(i, (String)(int_workshops[i][0]),(int)(int_workshops[i][1]),(int)(int_workshops[i][2]) );
- }
- //make Array of pariticipants, teilnehmer=participant german/english nothing related to the programm
- Teilnehmer[] teilnehmer = new Teilnehmer[int_teilnehmer.length];
- for(int i=0; i<int_teilnehmer.length; i++){
- teilnehmer[i] = new Teilnehmer(i, int_teilnehmer[i]);
- }
- System.out.println(Arrays.toString(workshops));
- System.out.println(Arrays.toString(teilnehmer));
- //testing if value of participants is enough to fill all workshops, if not fill the ones with the smallest min value with
- //the participants wich chose the same workshop twice or didnt chose at all or wrote a funny name on the paper for registration
- System.out.println("Programmende");
- }
- }
- class Teilnehmer{
- int tnr;
- int[] favs; //favorits
- public Teilnehmer(int tnr, int[] favs){
- this.tnr=tnr;
- for(int i=0; i<favs.length; i++)
- for(int j=i+1; j<favs.length; j++)
- if( favs[i]==favs[j] )
- throw new IllegalArgumentException("Duplikate bei Favoriten: TN="+this.tnr+ " favs="+Arrays.toString(favs));
- this.favs = new int[favs.length];
- for (int i = 0; i < favs.length; i++) {
- this.favs[i] = favs[i];
- }
- }
- public String toString(){
- return "TN: " + tnr + " Favoriten: " + Arrays.toString( favs );
- }
- }
- class Workshop{
- int wnr;
- String name;
- int min;
- int max;
- public Workshop(int wnr, String name, int min, int max){
- this.wnr=wnr;
- this.name= (name==null||name.length()==0)?("WS"+wnr):name;
- if(min>max)
- throw new IllegalArgumentException("Workshop Nr=" + wnr + " min="+min+" max="+max);
- this.min=min;
- this.max=max;
- }
- public String toString(){
- return name + "(" + min + "-" + max + ")";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement