Results 1 to 5 of 5
  1. #1
    twiggy62's Avatar
    twiggy62 is offline Member
    Join Date
    Feb 2010
    Posts
    26
    Rep Power
    0

    Default Assignment due tonight, please help me!

    Ok, I must be losing it. I have been working on this project for over 20 hrs.
    total. It should be easy as heck to do, but for some reason I cannot get it. I
    think it is partly to do with the instructions, they seem real vague, I don't
    understand exactly what I am to do. They read:

    "Create a class called MusicCollection. This class must have member inner
    classes called Artist and Recording. The Recording class must have an inner
    class called Track that represents a single piece of music within a Recording
    object. A MusicCollection object must have an array of Artist objects and an
    array of Recording objects. Recording objects must have a single Artist object,
    for simplicity, and an array of Track objects. Add a main method to
    MusicCollection that tests the creation of all these objects."


    This is what I have so far, any help would be greatly appreciated, or even
    letting me know if I am on the right track, or if I am completely off.

    Java Code:
    /**
     * @author twiggy62
     */
    public class MusicCollection {
    
        private int totalArtists = 0;
        private int totalRecordings = 0;
        private static final int ARRAY_LENGTH = 3;
        private Artist[] artistObjects = new Artist[ARRAY_LENGTH];
        private Recording[] recordingObjects = new Recording[ARRAY_LENGTH];
    
        /**
         * Test the creation of all objects
         * @param args The command line arguments
         * @exception Exception if a failure occurs while adding a object
         */
        public static void main(String[] args) throws Exception {
            MusicCollection mc = new MusicCollection();
            Artist art1 = mc.new Artist("twig");
            Artist art2 = mc.new Artist("twiggy");
            Artist art3 = mc.new Artist("tiggy62");
            Recording rec1 = mc.new Recording("1");
            Recording rec2 = mc.new Recording("2");
            Recording rec3 = mc.new Recording("3");
            System.out.println(mc);
        }
    
        /**
         * Provide a string representing the MusicCollection
         * @return string Representation of the object
         */
        @Override
        public String toString() {
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < artistObjects.length; i++) {
                sb.append("Artist" + (i + 1) + ":" + artistObjects[i].artist
                        + " Recording: " + recordingObjects[i].record + " ");
            }
            return sb.toString();
        }
    
        public class Artist {
    
            private String artist;
    
            public Artist(String name) {
                artist = name;
    
                if (totalArtists < ARRAY_LENGTH) {
                    artistObjects[totalArtists++] = this;
                }
            }
        }
    
        public class Recording {
    
            private String record;
    
            public Recording(String name) {
                record = name;
    
                if (totalRecordings < ARRAY_LENGTH) {
                    recordingObjects[totalRecordings++] = this;
                }
            }
    
            public class Track {
    
                private String track;
    
                public Track(String name) {
                    track = name;
    
                }
            }
        }
    }
    Last edited by twiggy62; 02-09-2010 at 01:40 AM.
    The biggest room in the world, is room for improvement.

  2. #2
    twiggy62's Avatar
    twiggy62 is offline Member
    Join Date
    Feb 2010
    Posts
    26
    Rep Power
    0

    Default

    Wow... no responses. :confused:

    Is this project a stumper?
    The biggest room in the world, is room for improvement.

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

    Default

    Quote Originally Posted by twiggy62 View Post
    Wow... no responses. :confused:

    Is this project a stumper?
    Nah, it's a "here's my homework, fix it for me" post which often doesn't get many responses. You're far better off telling us exactly what is working, what isn't, etc, in other words, making it as easy as possible for others to help you.

    Much luck.

  4. #4
    twiggy62's Avatar
    twiggy62 is offline Member
    Join Date
    Feb 2010
    Posts
    26
    Rep Power
    0

    Default

    Yeah I understand. :(

    I'll just turn it in the way it is for now then correct it when I have more time. I already spent way to much time on this project.
    The biggest room in the world, is room for improvement.

  5. #5
    [RaIdEn] is offline Senior Member
    Join Date
    Oct 2009
    Location
    California,US
    Posts
    201
    Rep Power
    6

    Default

    Quote Originally Posted by twiggy62 View Post
    Ok, I must be losing it. I have been working on this project for over 20 hrs.
    total. It should be easy as heck to do, but for some reason I cannot get it. I
    think it is partly to do with the instructions, they seem real vague, I don't
    understand exactly what I am to do. They read:

    "Create a class called MusicCollection. This class must have member inner
    classes called Artist and Recording. The Recording class must have an inner
    class called Track that represents a single piece of music within a Recording
    object. A MusicCollection object must have an array of Artist objects and an
    array of Recording objects. Recording objects must have a single Artist object,
    for simplicity, and an array of Track objects. Add a main method to
    MusicCollection that tests the creation of all these objects."


    This is what I have so far, any help would be greatly appreciated, or even
    letting me know if I am on the right track, or if I am completely off.

    Java Code:
    /**
     * @author twiggy62
     */
    public class MusicCollection {
    
        private int totalArtists = 0;
        private int totalRecordings = 0;
        private static final int ARRAY_LENGTH = 3;
        private Artist[] artistObjects = new Artist[ARRAY_LENGTH];
        private Recording[] recordingObjects = new Recording[ARRAY_LENGTH];
    
        /**
         * Test the creation of all objects
         * @param args The command line arguments
         * @exception Exception if a failure occurs while adding a object
         */
        public static void main(String[] args) throws Exception {
            MusicCollection mc = new MusicCollection();
            Artist art1 = mc.new Artist("twig");
            Artist art2 = mc.new Artist("twiggy");
            Artist art3 = mc.new Artist("tiggy62");
            Recording rec1 = mc.new Recording("1");
            Recording rec2 = mc.new Recording("2");
            Recording rec3 = mc.new Recording("3");
            System.out.println(mc);
        }
    
        /**
         * Provide a string representing the MusicCollection
         * @return string Representation of the object
         */
        @Override
        public String toString() {
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < artistObjects.length; i++) {
                sb.append("Artist" + (i + 1) + ":" + artistObjects[i].artist
                        + " Recording: " + recordingObjects[i].record + " ");
            }
            return sb.toString();
        }
    
        public class Artist {
    
            private String artist;
    
            public Artist(String name) {
                artist = name;
    
                if (totalArtists < ARRAY_LENGTH) {
                    artistObjects[totalArtists++] = this;
                }
            }
        }
    
        public class Recording {
    
            private String record;
    
            public Recording(String name) {
                record = name;
    
                if (totalRecordings < ARRAY_LENGTH) {
                    recordingObjects[totalRecordings++] = this;
                }
            }
    
            public class Track {
    
                private String track;
    
                public Track(String name) {
                    track = name;
    
                }
            }
        }
    }
    for the recording class i think it said
    Recording objects must have a single Artist object
    isnt it. chk that whether your missing in adding the Artist object and the array of tracks.

Similar Threads

  1. Need with my assignment ...
    By allergy01 in forum New To Java
    Replies: 1
    Last Post: 04-25-2009, 08:33 AM
  2. Can somebody help me in my assignment
    By coolstruxx in forum NetBeans
    Replies: 0
    Last Post: 03-24-2009, 01:27 AM
  3. GUI First Assignment-DUE 8/1/08
    By ljk8950 in forum AWT / Swing
    Replies: 2
    Last Post: 08-01-2008, 04:23 AM
  4. First GUI Assignment
    By ljk8950 in forum New To Java
    Replies: 1
    Last Post: 07-31-2008, 07:29 AM
  5. for Assignment plz help
    By assamhammad in forum New To Java
    Replies: 1
    Last Post: 11-06-2007, 08:35 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
  •