title: Using inheritance and dialog box in java
body: <p>I have three classes in java that i created:</p>
  
  <p>CollegeCourse</p>
  
  <pre><code>package CollegeCourse;
  import javax.swing.JOptionPane;
  public class CollegeCourse {
  
  protected String Dept;
  protected int CourseNum;
  protected int Cred;
  protected int fee;
  protected int Charge = 120;
  protected int labfee;
  
  public void inputDepartment(){
      Dept = JOptionPane.showInputDialog(null, "Enter Department");
  }
  
  public void inputCourseNumber(){
      String CourseNumString = new String(" ");
      CourseNumString = JOptionPane.showInputDialog(null, "Enter Course Number");
      CourseNum = Integer.parseInt(CourseNumString);
  }
  
  public void inputCredits(){
      String CredString = new String(" ");
      CredString = JOptionPane.showInputDialog(null, "Enter Credits");
      Cred = Integer.parseInt(CredString);
  }
  
   public void displayNonLabCourse(){
      fee = Cred * Charge;
      JOptionPane.showMessageDialog(null, Dept + CourseNum + 
              "\nNon-lab Course" + "\n" + Cred +" Credits" + "\nTotal fee is $" + fee);
   }
  </code></pre>
  
  <p>}</p>
  
  <p>LabCourse</p>
  
  <pre><code>package CollegeCourse;
  import javax.swing.JOptionPane;
  public class LabCourse extends CollegeCourse {
  
   public void displayLabCourse(){
      labfee = fee + 50;
      JOptionPane.showMessageDialog(null, Dept + CourseNum + 
              "\nLab Course" + "\n" + Cred +" Credits" + "\nTotal fee is $" + fee);
   }
   }
  </code></pre>
  
  <p>UseCourse</p>
  
  <pre><code>package CollegeCourse;
  public class UseCourse{
  public static void main(String[] args) {
      CollegeCourse college = new CollegeCourse();
      college.inputDepartment();
      college.inputCourseNumber();
      college.inputCredits();
      college.displayNonLabCourse();
      }
  }
  </code></pre>
  
  <p>How can i make the UseCourse class display the LabCourse display method when the user enters a certain department like "BIO"???</p>
  
  <p>Create a class named CollegeCourse that includes data fields that hold the department
  (for example, ENG), the course number (for example, 101), the credits (for example 3),
  and fee for the course (for example, $360). All of the fields are required as arguments
  to the constructor, except for the fee, which is calculated at $120 per credit hour.
  Include a display() method that displays course data. Create a subclass named LabCourse that
  adds $50 to the course fee. Override the parent class display() method to indicate that the
  course is a lab course to display all the data. Write an application named UseCourse that
  prompts the user for information. If the user enters a class in any of the following departments,
  create a LabCourse: BIO, CHM, CIS, or PHY. If the user enters any other departments, create
  a CollegeCourse that does not include the lab fee. Then display the course data. Save the files
  as CollegeCourse.java, LabCourse.java, and UseCourse.java.</p>