Results 1 to 5 of 5
  1. #1
    Lorelei7 is offline Member
    Join Date
    Nov 2013
    Posts
    14
    Rep Power
    0

    Default Multiple classes in a program help

    Hello! I am in my first java programming class and we were not shown how to accomplish this... We were assigned a group project creating our own classes and it requires 2 separate classes and then the demo class. I am unsure if the second class is written within the demo class? and then the main "library" class has the getters and setters for both? or if there is supposed to be TWO classes separate that have their own setters and getters and then the info is captured into ONE demo....

    Any insight would be great!

  2. #2
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    340
    Rep Power
    5

    Default Re: Multiple classes in a program help

    Classes are basically a blueprint from which individual objects are created(instances of the class).
    So more than likely, you will create your 2 classes, and then inside of your main method in your Demo class,
    you would be creating instances of those classes and manipulating them in some way.
    If you can give a little more detail on what your assignment is, you can probably get more specific help.

  3. #3
    Lorelei7 is offline Member
    Join Date
    Nov 2013
    Posts
    14
    Rep Power
    0

    Default Re: Multiple classes in a program help

    We are just now starting the code. Basically, the idea (simple as it may seem) will be for a patron at a library's online site, doing a book query and reservation. The customer attributes are one class and the book choice is the class and then we are going to have the demo side to gather all the info in dialog boxes and then output it in a dialog box, simply naming the book choice (title, author) entered along with their card number(an attribute of customer) and name.

    I hope this helps. And FYI what you DID say helped a bunch, still haven't heard from my instructor... sigh..

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    2,945
    Rep Power
    4

    Default Re: Multiple classes in a program help

    For additional help, check out the tutorials linked in my signature. They provide a good overview from basic stuff to advanced.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  5. #5
    natdizzle's Avatar
    natdizzle is offline Nathan Nelson
    Join Date
    Jan 2009
    Posts
    100
    Rep Power
    0

    Default Re: Multiple classes in a program help

    your first class in your IDE in a .class file:

    software you need to write 2 classes in seperate files:
    Java SE Development Kit 7 - Downloads | Oracle Technology Network | Oracle
    Eclipse Downloads

    Java Code:
    secondClass second;
    class myFirstClass{
    public static void Main(String[] args){
    new myFirstClass();
    }
    public myFirstClass(){
    second = new secondClass();
    }
    }
    your second class (in a new .class file in your ide):
    Java Code:
    class secondClass(){ //demo class
    public secondClass(){
    System.out.println("Message");
    }
    }
    thats it - your ide will catch my syntax errors if any

Similar Threads

  1. how to use get and set methods for multiple classes
    By comptechgivinsky in forum New To Java
    Replies: 3
    Last Post: 11-06-2012, 05:14 PM
  2. Help with multiple classes
    By Aimforthehead in forum New To Java
    Replies: 28
    Last Post: 11-27-2011, 11:01 PM
  3. Multiple images from different classes
    By superbriggs in forum Java 2D
    Replies: 1
    Last Post: 03-20-2011, 08:59 AM
  4. Multiple classes
    By Lund01 in forum New To Java
    Replies: 1
    Last Post: 03-16-2011, 02:58 PM
  5. help with GUI and multiple classes
    By sssss in forum Advanced Java
    Replies: 14
    Last Post: 01-16-2011, 10:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •