// CarTester.java // Tests user-defined class Car import javax.swing.*; // import user-defined class Car in edu.lehigh.notes package import edu.lehigh.notes.Car; public class CarTester { public static void main( String args[ ] ) { // references to Car objects Car chevy; Car boxster; Car jeep; Car honda; Car audi; String output, s1, s2; chevy = new Car( "Chevy", 125, 6.7, 8.3, false ); boxster = new Car( "Boxster", 145, 6.0, 6.1, true ); jeep = new Car( "Wrangler", 94, 9.5, 10.3, true ); honda = new Car( "Prelude", 7.2, 7.8, false ); // no top speed passed audi = new Car( "S4", 145, 5.5, 5.9, true ); output = ""; s1 = "It goes from 0 to 60 to 0 in "; s2 = " seconds."; if ( chevy.getSexy( ) == true ) { output += chevy.toString( ) + "\n"; output += s1 + chevy.perform( ) + s2 + "\n"; } if ( boxster.getSexy( ) == true ) { output += boxster.toString( ) + "\n"; output += s1 + boxster.perform( ) + s2 + "\n"; } if ( jeep.getSexy( ) == true ) { output += jeep.toString( ) + "\n"; output += s1 + jeep.perform( ) + s2 + "\n"; } if ( honda.getSexy( ) == true ) { output += honda.toString( ) + "\n"; output += s1 + chevy.perform( ) + s2 + "\n"; } if ( audi.getSexy( ) == true ) { output += honda.toString( ) + "\n"; output += s1 + audi.perform( ) + s2; } JOptionPane.showMessageDialog( null, output, "Sexy Cars", JOptionPane.INFORMATION_MESSAGE ); System.exit( 0 ); } }