Results 1 to 5 of 5
  1. #1
    Boysie is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Default Object Orientation - Arrays

    My name is Aaron Boyse and I am writing a Java Program Object Orientation. I need to be able to Add a student, Delete a student, List all students and then exit in a menu form. NEED HELP!!!.

  2. #2
    programmer_007's Avatar
    programmer_007 is offline Senior Member
    Join Date
    Aug 2009
    Posts
    125
    Rep Power
    0

    Default

    My name is Aaron Boyse and I am writing a Java Program Object Orientation. I need to be able to Add a student, Delete a student, List all students and then exit in a menu form. NEED HELP!!!.
    good ....Go Ahead !! write it

  3. #3
    programmer_007's Avatar
    programmer_007 is offline Senior Member
    Join Date
    Aug 2009
    Posts
    125
    Rep Power
    0

    Default

    Perhaps you should have chosen the appropriate place for this thread !
    :mad:
    its not a correct place to post this thread !
    Anyways .. start from da scratch.. write a class...with appropriate data members and methods.. write some code,, if u get any problem.. post it here.:D

  4. #4
    Boysie is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Talking Object Orientation - Arrays

    class studentUse

    {




    public static void menu()

    {
    System.out.println(" Menu ");
    System.out.println(" ---------- ");
    System.out.println();
    System.out.println(" 1. Add ");
    System.out.println(" 2. Delete ");
    System.out.println(" 3. List All ");
    System.out.println(" 4. Exit ");

    }

    public static void clearScreen()

    {
    int index;
    String student;
    int studentNumber;
    int studentAge;

    for (index = 0; index < 25; index ++)
    {
    System.out.println("Enter student");
    student = EasyIn.getString();
    System.out.println("Enter student Number");
    studentNumber = EasyIn.getInt();
    System.out.println("Enter student Age");
    studentAge = EasyIn.getInt();

    }

    }

    public static void options()

    {

    char option;
    String student;
    menu();
    System.out.println();
    System.out.println("Enter Option Required (1-4) ");
    option = EasyIn.getChar();
    while (option != '4')
    {

    switch(option)
    {
    case '1': System.out.println("Add Student");
    EasyIn.pause();
    break;
    case '2': System.out.println("Delete Student");
    EasyIn.pause();
    break;
    case '3': System.out.println("List All");
    EasyIn.pause();
    break;
    default: System.out.println("Invalid Option!");
    EasyIn.pause();
    }
    clearScreen();
    menu();
    System.out.println();
    System.out.println("Enter Option Required (1-4) ");
    option = EasyIn.getChar();
    }
    }

    public static void main(String args[])

    {

    }
    }

    Got it that far now i need help getting it the rest of the way

  5. #5
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Use CODE tags -- they make your code much easier to read and understand here.

    Java Code:
    class studentUse
    Start your class name with an upper-case letter -- StudentUse rather than studentUse. Also, choose a good class name -- a singular noun that describes what the class will model. If the class's only purpose is to run a program like this, call it StudentProgram or something like that.
    Java Code:
    {
            public static void menu()
    	{
    		System.out.println("    Menu    ");
    		System.out.println(" ----------   ");
    		System.out.println();
    		System.out.println("  1. Add    ");
    		System.out.println("  2. Delete ");
    		System.out.println("  3. List All ");
    		System.out.println("  4. Exit   ");
    	}
    	
            public static void clearScreen()
            {
    	        int index;
    	        String student;
    	        int studentNumber;
    	        int studentAge;
    	
    	        for (index = 0; index < 25; index ++)
    		{
    			System.out.println("Enter student");
    			student = EasyIn.getString();
    			System.out.println("Enter student Number");
    			studentNumber = EasyIn.getInt();
    			System.out.println("Enter student Age");
    			studentAge = EasyIn.getInt();
    		}
            }
    I don't think this is what you want. You are asking the user to enter a student (do you mean name?), a student Number and a student Age 25 times, and you are only saving the last one. Besides which, a method named clearScreen() should concern itself only with clearing the screen, and not with prompting the user for input.
    Java Code:
            public static void options()
            {
                    char option;
                    String student;
                    menu();
                    System.out.println();
                    System.out.println("Enter Option Required (1-4) ");
                    option = EasyIn.getChar(); 
                    while (option != '4')
    	        {
                            switch(option) 
    		       {
       			case '1': System.out.println("Add Student");
       				EasyIn.pause();
        	   	      		break;
       			case '2': System.out.println("Delete Student");
       				EasyIn.pause();
           		      		break;
       			case '3': System.out.println("List All");
       				EasyIn.pause();
           		      		break;
       			default:  System.out.println("Invalid Option!");
       				EasyIn.pause();
     		        }
    So you need some new methods here -- maybe addStudent(), deleteStudent() and listAllStudents()? You are going to need storage for your student data, and the Java way to do this would be to create a Student class, and then most likely a List<Student> in this class to store them in. Maybe your instructor doesn't want you creating classes yet, though, so you could get away with a String[] studentName, int[] studentNumber and int[] studentAge. These three arrays should be instance variables of this class.
    Java Code:
    		        clearScreen();
    		        menu();
    		        System.out.println();
    		        System.out.println("Enter Option Required (1-4) ");
    		        option = EasyIn.getChar();
                    }
            }
    
            public static void main(String args[])
            {
       
            }
    You probably want to call options() here?
    Java Code:
    }
    Hope that helps!

    -Gary-

Similar Threads

  1. Object Arrays
    By rsvr in forum New To Java
    Replies: 9
    Last Post: 12-06-2009, 12:27 AM
  2. Multiple columns right to left orientation
    By marjanzfz in forum New To Java
    Replies: 2
    Last Post: 11-12-2009, 04:33 AM
  3. Question on Object Orientation Topic
    By DrMath in forum New To Java
    Replies: 1
    Last Post: 09-29-2009, 08:07 PM
  4. change viewing platform orientation
    By Bit2_Gosu in forum New To Java
    Replies: 1
    Last Post: 02-15-2009, 09:46 AM
  5. Replies: 2
    Last Post: 12-10-2008, 05:40 PM

Tags for this Thread

Posting Permissions

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