/* 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 FlightClass { public String Airline, Route, Price; public boolean FreqFlier, Movie; public int Score; public Label FlightLabel; FlightClass(String airline, String route, String price, boolean freqflier, boolean movie, int score) { StringBuffer tmpString = new StringBuffer(128); Airline = new String(airline); Route = new String(route); Price = new String(price); FreqFlier = freqflier; Movie = movie; Score = score; tmpString.append(airline); for(int j=tmpString.length(); j<15; j++) tmpString.append(" "); tmpString.append(route); for(int j=tmpString.length(); j<29; j++) tmpString.append(" "); tmpString.append(price); for(int j=tmpString.length(); j<38; j++) tmpString.append(" "); if(freqflier) { tmpString.append("Freq. Flier"); } else { tmpString.append("Not Freq. Flier"); } for(int j=tmpString.length(); j<57; j++) tmpString.append(" "); if(movie) { tmpString.append("Movie"); } else { tmpString.append("No Movie"); } FlightLabel = 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 { FlightClass Flights[] = new FlightClass[18]; int LabelHeight = 15, LabelWidth = 460; int LabelSelected = -1, MouseEntered = -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 Part Worths / Relative Importances"); Label AttributeLevel = new Label("Attribute level:"), PartWorth = new Label("Part Worths"), AttributeLabels[] = new Label[13], AttributePW[] = new Label[13]; Label RIAttributeLabel = new Label("Attribute:"), RI = new Label("Relative Importance"), RIAirlineLabel = new Label("Airline"), RIRouteLabel = new Label("Route"), RIPriceLabel = new Label("Price"), RIFFPLabel = new Label("Frequent Flier Program"), RIMovieLabel = new Label("Movie"), RIAirline = new Label("-"), RIRoute = new Label("-"), RIPrice = new Label("-"), RIFFP = new Label("-"), RIMovie = new Label("-"); int GraphStartYpos = 5000, // Definately off of the screen Output1StartYpos = 5000, Output2StartYpos = 5000, InputStartYpos = 5000; int TargetID = -1; public void init() { int Xpos, Ypos; this.addMouseListener(this); this.addMouseMotionListener(this); Flights[0] = new FlightClass("American", "Non-Stop", "$350", true, true, 18); Flights[1] = new FlightClass("American", "Direct", "$400", false, false, 17); Flights[2] = new FlightClass("American", "Connecting", "$450", true, true, 16); Flights[3] = new FlightClass("Delta", "Non-Stop", "$400", true, true, 15); Flights[4] = new FlightClass("Delta", "Direct", "$450", true, false, 14); Flights[5] = new FlightClass("Delta", "Connecting", "$350", false, true, 13); Flights[6] = new FlightClass("Continental", "Non-Stop", "$450", true, true, 12); Flights[7] = new FlightClass("Continental", "Direct", "$350", false, true, 11); Flights[8] = new FlightClass("Continental", "Connecting", "$400", true, false, 10); Flights[9] = new FlightClass("American", "Non-Stop", "$450", false, false, 9); Flights[10] = new FlightClass("American", "Direct", "$350", true, true, 8); Flights[11] = new FlightClass("American", "Connecting", "$400", true, true, 7); Flights[12] = new FlightClass("Delta", "Non-Stop", "$350", true, false, 6); Flights[13] = new FlightClass("Delta", "Direct", "$400", true, true, 5); Flights[14] = new FlightClass("Delta", "Connecting", "$450", false, true, 4); Flights[15] = new FlightClass("Continental", "Non-Stop", "$400", false, true, 3); Flights[16] = new FlightClass("Continental", "Direct", "$450", true, true, 2); Flights[17] = new FlightClass("Continental", "Connecting", "$350", true, false, 1); Attributes[0] = new AttributeClass("Airline: American"); Attributes[1] = new AttributeClass("Airline: Delta"); Attributes[2] = new AttributeClass("Airline: Continental"); Attributes[3] = new AttributeClass("Route: Non-Stop"); Attributes[4] = new AttributeClass("Route: Direct"); Attributes[5] = new AttributeClass("Route: Connecting"); Attributes[6] = new AttributeClass("Price: $350 Round Trip"); Attributes[7] = new AttributeClass("Price: $400 Round Trip"); Attributes[8] = new AttributeClass("Price: $450 Round Trip"); Attributes[9] = new AttributeClass("Frequent Flier: Enrolled in program"); Attributes[10] = new AttributeClass("Frequent Flier: Not enrolled in program"); Attributes[11] = new AttributeClass("Movie Status: Movie during flight"); Attributes[12] = new AttributeClass("Movie Status: No movie during flight"); 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<6; 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 = 6; k<9; 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 = 9; 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)); } TargetID = -1; LabelSelected = -1; 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