I am getting a null pointer exception and can not figure out what I'm missing here. Does anyone have any idea what I'm missing?
import javax.swing.*;
public class Truck{
public int [] choice;
public String [] model;
public int [] cd;
public int [] speaker;
public int [] cost;
public int choiceCount;
public int modelCount;
public int cdCount;
public int speakerCount;
public int costCount;
public String summaryOutput;
public void Truck(){
choice = new int[100];
model = new String[100];
cd = new int[100];
speaker = new int[100];
cost = new int[100];
choiceCount = 0;
modelCount = 0;
cdCount = 0;
speakerCount = 0;
costCount = 0;
summaryOutput = "";
}//end Truck method
public String WithSpeakerSummary(){
for(int i = 0; i < choiceCount; i++){
if(choice[i] == 1){
summaryOutput += "Cars with Stereos:/nModel: " + model[i] +
"/nCost: " + cost[i] +
"/n# CDs: " + cd[i] +
"/n# Speakers: " + speaker[i] +
"/n/n";
}//end if statement
}//end
return summaryOutput;
}//end Summary method
public String WithOutSpeakerSummary(){
for(int i = 0; i < choiceCount; i++){
if(choice[i] == 0){
summaryOutput += "Cars with Stereos:/nModel: " + model[i] +
"/nCost: " + cost[i] +
"/n/n";
}//end if statement
}//end
return summaryOutput;
}//end Summary method
public void addWithChoice(int w){
choice[choiceCount++] = w;
}//end addWithChoice method
public void addWithoutChoice(int wo){
choice[choiceCount++] = wo;
}//end addWithoutChoice method
public void addModel(String m){
model[modelCount++] = m;
}//end addModel method
public void addCD(int c){
cd[cdCount++] = c;
}//end addModel method
public void addSpeaker(int s){
speaker[speakerCount++] = s;
}//end addModel method
public void addCost(int t){
cost[costCount++] = t;
}//end addModel method
}//end Truck super class
import javax.swing.*;
public class TruckWithStereo extends Truck{
public static void main(String[] args){
int aChoice = 0;
String aModel = "";
int aCD = 0;
int aSpeaker = 0;
int aCost = 0;
Truck tObject = new Truck();
do{
while(JOptionPane.showConfirmDialog(null, "Does this car have a stereo?") == JOptionPane.YES_OPTION){
//with speakers
aChoice = 1;
tObject.addWithChoice(aChoice);
aModel = JOptionPane.showInputDialog("Model of car?");
tObject.addModel(aModel);
aCD = Integer.parseInt(JOptionPane.showInputDialog("How many CDs in the player?"));
tObject.addCD(aCD);
aSpeaker = Integer.parseInt(JOptionPane.showInputDialog("How many speakers in the car?"));
tObject.addSpeaker(aSpeaker);
aCost = Integer.parseInt(JOptionPane.showInputDialog("Cost of car?"));
tObject.addCost(aCost);
}//end YES Option while loop
while(JOptionPane.showConfirmDialog(null, "Does this car have a stereo?") == JOptionPane.NO_OPTION){
//without speakers
aChoice = 0;
tObject.addWithoutChoice(aChoice);
aModel = JOptionPane.showInputDialog("Model of car?");
tObject.addModel(aModel);
aCost = Integer.parseInt(JOptionPane.showInputDialog("Cost of car?"));
tObject.addCost(aCost);
}//end NO Option while loop
}while(JOptionPane.showConfirmDialog(null, "Still looking for cars?") == JOptionPane.YES_OPTION);//end do-while loop
if(JOptionPane.showConfirmDialog(null, "Do you want to see cars with stereos?") == JOptionPane.YES_OPTION){
tObject.WithSpeakerSummary();
}//end YES Option while loop
else if(JOptionPane.showConfirmDialog(null, "Do you want to see cars with stereos?") == JOptionPane.NO_OPTION){
tObject.WithOutSpeakerSummary();
}//end NO Option while loop
}//end main method
}//end TruckWithStereo subclass