Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Class Driver help

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Class Driver help

    Hello all, I require some help and I hope I am in the right forum.
    I have a project I am attempting to do requiring me to build a window that accepts an input for a student ID number, and answers for a quiz to be taken. The window will have text fields for input of an answer to a question, which will be input into an array, compared with another array which holds the answer key, and then both of those shall be compared with a third which holds points for the correct answer. None of that is related to my problem now, but I thought it might help give an idea of what I am trying to envision the program to do. Right now I have two files, my main class file and my driver file (excuse me if I am naming them incorrectly). In my Class file, I have two void functions that are building the first panel for the user to input his/her student ID number. I have the panel fully built, I believe, besides the button's action listener to apply the information to the variable I set for it. In the driver file, I created a new object, and now I am trying to figure out a way to display it just to test my progress, but I am coming up short, and I cannot seem to find any resources to indicate what or how to do it. I apologize if this is an obvious mistake, but I don't see what I am doing wrong. I would appreciate any help in the matter, as well as any suggestions.
    Thank you to anyone who can or will help.

    Here is my class file.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
     
    public class Quiz extends JFrame
    {
        private int studentID;
        final private int SIZE = 8;
        private char[] quizAnswerkey = {'a', 'c', 'd', 'd', 'b', 'a', 'c', 'a'};
        private char[] quizAnswers = new char[SIZE];
        private int[] quizPoints = {10, 5, 10, 5, 5, 15, 20, 10};
        private JLabel messageLabel;
        private JTextField idText;
        private JButton storeButton;
        private JPanel panel;
     
     
        public void ID()
        {
            setTitle("Student ID info");
     
            setSize(310, 100);
     
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
            buildIDpanel();
     
            add(panel);
     
            setVisible(true);
     
        }
        private void buildIDpanel()
        {
            messageLabel = new JLabel("Please enter your student ID number");
     
            idText = new JTextField(15);
     
            storeButton = new JButton("Input");
     
            panel = new JPanel();
     
            panel.add(messageLabel);
            panel.add(idText);
            panel.add(storeButton);
     
     
        }
     
     
     
    }

    and here is my driver file
    public class QuizDriver 
     
    {
        public static void main(String args[] )
        {
         Quiz quiz = new Quiz();
         quiz.
        }
     
    }


  2. #2
    Junior Member
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Class Driver help

    I think that in programming approach you need first write the logic of your application, in separate class, and then think on how the user can interact with your application.

  3. #3
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Class Driver help

    System.out.println(quiz.toString());

Similar Threads

  1. For loop Driver Testing
    By PeskyToaster in forum Loops & Control Statements
    Replies: 1
    Last Post: January 31st, 2012, 12:27 AM
  2. Implementing a Driver to following code
    By Twoacross in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 11th, 2011, 11:17 PM
  3. [SOLVED] Help with creating a class and driver
    By JackCannon15 in forum Object Oriented Programming
    Replies: 1
    Last Post: October 27th, 2011, 03:50 PM
  4. [SOLVED] Project help...confusion with changing a getter/setter for a driver class
    By coolidge in forum Java Theory & Questions
    Replies: 1
    Last Post: September 30th, 2011, 11:08 PM
  5. Link From A Driver Class To The Subclasses
    By angels in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 29th, 2011, 07:39 AM