Sponsors: Michael Fertik - Best JAVA Web hosting Company & 30% off


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-09-2010, 01:36 AM
twiggy62's Avatar
Member
 
Join Date: Feb 2010
Posts: 26
Rep Power: 0
twiggy62 is on a distinguished road
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.

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;

            }
        }
    }
}
__________________
The biggest room in the world, is room for improvement.

Last edited by twiggy62; 02-09-2010 at 01:40 AM.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 02-09-2010, 03:46 AM
twiggy62's Avatar
Member
 
Join Date: Feb 2010
Posts: 26
Rep Power: 0
twiggy62 is on a distinguished road
Default
Wow... no responses.

Is this project a stumper?
__________________
The biggest room in the world, is room for improvement.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-09-2010, 03:49 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 8,388
Rep Power: 11
Fubarable is on a distinguished road
Default
Originally Posted by twiggy62 View Post
Wow... no responses.

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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 02-09-2010, 03:53 AM
twiggy62's Avatar
Member
 
Join Date: Feb 2010
Posts: 26
Rep Power: 0
twiggy62 is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 02-09-2010, 06:07 AM
Senior Member
 
Join Date: Oct 2009
Location: California,US
Posts: 195
Rep Power: 1
[RaIdEn] is on a distinguished road
Default
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.

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
Quote:
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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need with my assignment ... allergy01 New To Java 1 04-25-2009 08:33 AM
Can somebody help me in my assignment coolstruxx NetBeans 0 03-24-2009 01:27 AM
GUI First Assignment-DUE 8/1/08 ljk8950 AWT / Swing 2 08-01-2008 04:23 AM
First GUI Assignment ljk8950 New To Java 1 07-31-2008 07:29 AM
for Assignment plz help assamhammad New To Java 1 11-06-2007 08:35 PM


Java Forums is supported by the best jsp hosting.

All times are GMT +2. The time now is 08:59 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org