Results 1 to 7 of 7
Like Tree2Likes
  • 1 Post By DarrylBurke
  • 1 Post By Fubarable

Thread: Help with java assignment

  1. #1
    jason3460 is offline Member
    Join Date
    Dec 2012
    Posts
    21
    Rep Power
    0

    Default Help with java assignment

    Design a suitable static (array) list class (ADT) called UnitResults, to hold a collection of student details (forename, surname & result) and unit title (other data fields may need to be applied). The course that this unit belongs should be defined as a class member. Provide the ADT with the means of adding, deleting, updating, listing, sorting, searching and analysing the field data.

    Can I get some help with starting this assignment ? I just cant get my head around it!
    Thanks in advance!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Help with java assignment

    Pardon my ignorance, but what is an "ADT"?

    Also, can you tell us more about just where you're stuck, just what confuses you? The more you can tell us, likely the better we can help.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Help with java assignment

    Fubarable likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Help with java assignment

    Also, please go through the Forum Rules -- particularly the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    jason3460 is offline Member
    Join Date
    Dec 2012
    Posts
    21
    Rep Power
    0

    Default Re: Help with java assignment

    As far as I am aware an ADT is the base class, which is not used to create an object, a "menu" class is then made to use this base class to create an object of this class... or something along them lines!

    So i need to create -
    Two arrays: studentName and studentMark
    Three variables: Result, unitTitle and Course

    The studentName should hold forename and surname,
    and studentMark should hold the students mark (0-100).

    What I am having a problem with is how i would create these arrays, and when i go to create methods for adding/deleting etc. how would i set them up to add/delete both the student plus that students mark from anywhere within that array, help with this would be very much appreciated!!

    p.s. cross posting suggests across this forum or other forums, I don't believe yahoo answers is a forum... not to be cheeky or anything..

    EDIT:

    this is what I have so far:

    My main class:

    Java Code:
    package assignment1;
    
    public class UnitResults2 
    {
        private String [] studentName;
        private int [] studentMark;
        private int intResult;
        private String unitTitle;
        private static String course;
        private static int pointer;
        
    public UnitResults2()
        {
        }
    public String display()
        {
            String strOutput = "";
            strOutput = strOutput + "List Contents\n";
            
            if(pointer == 0)
                {    
                    strOutput = strOutput + "List Empty\n";
                    return strOutput;
                    //System.out.println("There are no Elemets in the Array\n");
                    //return;
                }
            
            for(int index = 0; index < pointer; index++)
                {
                    strOutput = strOutput + studentName[index] + "\n";
                }
            return strOutput;
        }//End of display Method
        
    public boolean add(String foreName, String surName, int mark)
        {
            if(pointer == studentName.length)
            {
                System.out.println("The Array is Full.\n");
                return false;
            }
            
            studentName[pointer] = (foreName + surName);
            studentMark[pointer] = mark;
            pointer++;
            
            return true;
        }//End of add Method.
        
    public boolean delete(int element)
        {
            element = element - 1; //array location
            if ((element >= 0) && (element < pointer))
            {
                for(int index = (element + 1); index < pointer; index ++)
                {
                    studentName[index -1] = studentName[index];
                    studentMark[index -1] = studentMark[index];
                }
                
                pointer--;
                return true;
            }
            else
            {
                return false;
            }
        }//End of delete Method
    }//end of Class
    My testing class:

    Java Code:
    package assignment1;
    
    public class TestUnitResults 
    {
        public static void main(String[] args) 
        {
            UnitResults2 myUnit = new UnitResults2();
            
            myUnit.add("Bob", "Simpson", 78);
    
            System.out.println(myUnit.display());
        }
    }
    When i run this testing class I'm getting this error:

    Exception in thread "main" java.lang.NullPointerException
    at assignment1.UnitResults2.add(UnitResults2.java:37)
    at assignment1.TestUnitResults.main(TestUnitResults.j ava:14)
    Java Result: 1

    so any help would be appreciated, thanks!
    Last edited by jason3460; 12-04-2012 at 10:34 PM.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Help with java assignment

    Quote Originally Posted by jason3460 View Post
    p.s. cross posting suggests across this forum or other forums, I don't believe yahoo answers is a forum... not to be cheeky or anything..
    Not to be cheeky, but semantics regarding what is or isn't a forum aside, try being a volunteer and spending time trying to answer a complex question only to find out later that it had been answered elsewhere hours before, and that you did not know to look because the person seeking help did not have the common decency to let you know about their cross-posts. Your opinion on this subject may then change. Most of us value our free time and appreciate others who respect this.
    DarrylBurke likes this.

  7. #7
    jason3460 is offline Member
    Join Date
    Dec 2012
    Posts
    21
    Rep Power
    0

    Default Re: Help with java assignment

    Okay well I'm sorry, although my question had not been answered elsewhere, therefore i thought joining a programming forum to help me with my java programming through my course/future career would be a good idea, so here i am!

Similar Threads

  1. JAVA assignment help
    By ScarabVenom in forum New To Java
    Replies: 1
    Last Post: 10-15-2012, 06:07 AM
  2. Java Assignment
    By lance215 in forum New To Java
    Replies: 1
    Last Post: 06-15-2012, 12:11 AM
  3. Help me please (Java assignment)
    By cris_carriaga in forum Java Applets
    Replies: 4
    Last Post: 10-06-2010, 04:11 PM
  4. java assignment, need help bad.
    By carlos123 in forum New To Java
    Replies: 1
    Last Post: 11-06-2007, 04:53 PM
  5. Help with my assignment java
    By toby in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:59 AM

Posting Permissions

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