/* Terms and Conditions * COPYRIGHT AND PERMISSION NOTICE * Copyright (c) 2000 eLab, Owen Graduate School of Management, Vanderbilt * University * All rights reserved. * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, and/or sell copies of the * Software, and to permit persons to whom the Software is furnished to do so, * provided that the above copyright notice(s) and this permission notice appear in * all copies of the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT * SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY * CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * Except as contained in this notice, the name of a copyright holder shall not be * used in advertising or otherwise to promote the sale, use or other dealings in * this Software without prior written authorization of the copyright holder. */ import java.applet.*; import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; class MovieClass { public String Price, View, Seat, Screen, Snack; public int Score; public Label MovieLabel; MovieClass(String price, String view, String seat, String screen, String snack, int score) { StringBuffer tmpString = new StringBuffer(128); Price = new String(price); View = new String(view); Seat = new String(seat); Screen = new String(screen); Snack = new String(snack); Score = score; tmpString.append(price); for(int j=tmpString.length(); j<6; j++) tmpString.append(" "); tmpString.append(view); for(int j=tmpString.length(); j<22; j++) tmpString.append(" "); tmpString.append(seat); for(int j=tmpString.length(); j<50; j++) tmpString.append(" "); tmpString.append(screen); for(int j=tmpString.length(); j<78; j++) tmpString.append(" "); tmpString.append(snack); for(int j=tmpString.length(); j<100; j++) tmpString.append(" "); MovieLabel = new Label(tmpString.toString()); } } class AttributeClass { public String Description; float AverageScore; float PartWorth; AttributeClass(String s) { Description = new String(s); AverageScore = 0.0f; PartWorth = 0.0f; } } public class conjoint extends Applet implements MouseListener, MouseMotionListener, ActionListener { MovieClass Movies[] = new MovieClass[18]; int LabelHeight = 15, LabelWidth = 650; int LabelSelected = -1, TargetID = -1; AttributeClass Attributes[] = new AttributeClass[13]; Font MonoFont = new Font("Courier", Font.PLAIN, 12); Font BigFont = new Font("TimesRoman", Font.BOLD, 14); int DoCalcs = 0; Label MostPreferred = new Label("Most Preferred "), LeastPreferred = new Label("Least Preferred"); Button CalcAvg = new Button("Calculate"); Label AttributeLevel = new Label("Attribute level:"), PartWorth = new Label("Part Worths"), AttributeLabels[] = new Label[13], AttributePW[] = new Label[13]; String TP = new String("Ticket Price"); String LoS = new String("Line of Sight"); String SC = new String("Seat Comfort"); String AV = new String("Audio / Visual"); String F = new String("Food"); String TP6 = new String("$6"); String TP8 = new String("$8"); String TP10 = new String("$10"); String LoSS = new String("staggered"); String LoSN = new String("not staggered"); String SC1 = new String("avg. seats no cup holder"); String SC2 = new String("avg. seats cup holder"); String SC3 = new String("big seats cup holder"); String AV1 = new String("small screen plain sound"); String AV2 = new String("large screen plain sound"); String AV3 = new String("large screen Digital THX"); String F1 = new String("dogs & popcorn"); String F2 = new String("gourmet snacks"); Label RIAttributeLabel = new Label("Attribute:"), RI = new Label("Relative Importance"), RITicketPriceLabel = new Label(TP), RILineOfSightLabel = new Label(LoS), RISeatComfortLabel = new Label(SC), RIAudioVisualLabel = new Label(AV), RIFoodLabel = new Label(F), RITicketPrice = new Label("-"), RILineOfSight = new Label("-"), RISeatComfort = new Label("-"), RIAudioVisual = new Label("-"), RIFood = new Label("-"); int GraphStartYpos = 5000, // Definately off of the screen Output1StartYpos = 5000, Output2StartYpos = 5000, InputStartYpos = 5000; public void init() { int Xpos, Ypos; this.addMouseListener(this); this.addMouseMotionListener(this); Movies[0] = new MovieClass(TP6, LoSS, SC1, AV1, F2, 18); Movies[1] = new MovieClass(TP6, LoSN, SC2, AV2, F1, 17); Movies[2] = new MovieClass(TP6, LoSS, SC3, AV3, F2, 16); Movies[3] = new MovieClass(TP10, LoSS, SC1, AV2, F2, 15); Movies[4] = new MovieClass(TP10, LoSS, SC2, AV3, F1, 14); Movies[5] = new MovieClass(TP10, LoSN, SC3, AV1, F2, 13); Movies[6] = new MovieClass(TP8, LoSS, SC1, AV3, F2, 12); Movies[7] = new MovieClass(TP8, LoSN, SC2, AV1, F2, 11); Movies[8] = new MovieClass(TP8, LoSS, SC3, AV2, F1, 10); Movies[9] = new MovieClass(TP6, LoSN, SC1, AV3, F1, 9); Movies[10] = new MovieClass(TP6, LoSS, SC2, AV1, F2, 8); Movies[11] = new MovieClass(TP6, LoSS, SC3, AV2, F2, 7); Movies[12] = new MovieClass(TP10, LoSS, SC1, AV1, F1, 6); Movies[13] = new MovieClass(TP10, LoSS, SC2, AV2, F2, 5); Movies[14] = new MovieClass(TP10, LoSN, SC3, AV3, F2, 4); Movies[15] = new MovieClass(TP8, LoSN, SC1, AV2, F2, 3); Movies[16] = new MovieClass(TP8, LoSS, SC2, AV3, F2, 2); Movies[17] = new MovieClass(TP8, LoSS, SC3, AV1, F1, 1); Attributes[0] = new AttributeClass(TP + ": " + TP6); Attributes[1] = new AttributeClass(TP + ": " + TP8); Attributes[2] = new AttributeClass(TP + ": " + TP10); Attributes[3] = new AttributeClass(LoS + ": " + LoSS); Attributes[4] = new AttributeClass(LoS + ": " + LoSN); Attributes[5] = new AttributeClass(SC + ": " + SC1); Attributes[6] = new AttributeClass(SC + ": " + SC2); Attributes[7] = new AttributeClass(SC + ": " + SC3); Attributes[8] = new AttributeClass(AV + ": " + AV1); Attributes[9] = new AttributeClass(AV + ": " + AV2); Attributes[10] = new AttributeClass(AV + ": " + AV3); Attributes[11] = new AttributeClass(F + ": " + F1); Attributes[12] = new AttributeClass(F + ": " + F2); for(int i=0; i Attributes[i].AverageScore ) MinAvgScore = Attributes[i].AverageScore; } // find the part worth scores for(int i=0; i Attributes[k].PartWorth) MinPW = Attributes[k].PartWorth; } RelImp[0] = MaxPW - MinPW; MaxPW = -1.0f; MinPW = 2.0f; for(int k = 3; k<5; k++) { if(MaxPW < Attributes[k].PartWorth) MaxPW = Attributes[k].PartWorth; if(MinPW > Attributes[k].PartWorth) MinPW = Attributes[k].PartWorth; } RelImp[1] = MaxPW - MinPW; MaxPW = -1.0f; MinPW = 2.0f; for(int k = 5; k<8; k++) { if(MaxPW < Attributes[k].PartWorth) MaxPW = Attributes[k].PartWorth; if(MinPW > Attributes[k].PartWorth) MinPW = Attributes[k].PartWorth; } RelImp[2] = MaxPW - MinPW; MaxPW = -1.0f; MinPW = 2.0f; for(int k = 8; k<11; k++) { if(MaxPW < Attributes[k].PartWorth) MaxPW = Attributes[k].PartWorth; if(MinPW > Attributes[k].PartWorth) MinPW = Attributes[k].PartWorth; } RelImp[3] = MaxPW - MinPW; MaxPW = -1.0f; MinPW = 2.0f; for(int k = 11; k<13; k++) { if(MaxPW < Attributes[k].PartWorth) MaxPW = Attributes[k].PartWorth; if(MinPW > Attributes[k].PartWorth) MinPW = Attributes[k].PartWorth; } RelImp[4] = MaxPW - MinPW; RawImpTotal = 0.0f; for(int k=0; k (InputStartYpos + 18 * (LabelHeight + 5) ) ) { return; } else { TargetScore = 18 - (int)Math.floor((double)(Ypos - InputStartYpos ) / (LabelHeight + 5)); } for(int i=0;i (InputStartYpos + 18 * (LabelHeight + 5) ) ) { TargetScore = 1; } else TargetScore = 18 - (int)Math.floor((double)(Ypos - InputStartYpos ) / (LabelHeight + 5)); } TargetID = -1; for(int i=0;i