Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Body Systems Class

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    8
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Body Systems Class

    This is an assignment given for an AP Computer Science Course, please help! My idea for the class was Body Systems, objects will be body systems. Here are the requirements given:

    ou will be designing a class that will demonstrate a variety of the topics discussed in the first three sections of chapter 4, including all of the basic elements of a class and overloading.

    Your class must include the following:

    -At least 3 pieces of instance data of different types

    -At least 2 constructors.

    - accessor methods for all of your instance data

    - 2 additional service methods
    - 1 support methods,

    Note: Each item listed above must be labeled with comments. For example, comments for one of the constructors might look like...

    // Constructor #1 that uses no parameters


    - Include a driver program to demonstrate that your class works as stated. In other words, you must show evidence that all constructors, service methods, and overloaded methods work as designed.

    I'm not sure I'm doing my methods correctly, and I'm not really understanding the concept of what a support method is supposed to do in regards to my class. Please help.

    public class BodySystems
    {
     
    //Instance Data 
    public String name; //Name of System
    public String purpose; //Purpose of System
    public boolean transport; //Y/N Involves transport of material in/out of body
    public String nameorg; //Name of organs
    public int organs; //# of Major Organs
     
    //Constructor #1
    public BodySystems(String name1, int organs1, String nameorg1) // What System, What Organs
    {
    name = name1;
    organs = organs1;
    nameorg = nameorg1;
    }
    //Constructor #2
    public BodySystems(String purpose1, boolean transport1) // Purpose, Y/N Involves transport of material in/out of body
    {
    purpose = purpose1;
    transport = transport1;
    }
     
    //Accessor Methods
    public String get_name()
    {
    return name;
    }
     
    public String get_purpose()
    {
    return purpose;
    }
     
    public boolean get_transport()
    {
    return transport;
    }
     
    public int get_organs()
    {
    return organs;
    }
     
    public String get_nameorg()
    {
    return nameorg;
    }
     
     
    //Method #1 (Support)
    private void whatSystem(int system)
    {
    for (system=1; system <= 7; system++)
    if(system == 1)
       name = "Skeletal System";
    else if (system == 2)
       name = "Muscular System";
    else if (system == 3)
       name = "Cardiovascular System";
    else if (system == 4)
       name = "Digestive System";
    else if (system == 5)
       name = "Nervous System";
    else if (system == 6)
       name = "Respiratory System";
    else if (system == 2)
       name = "Urinary System";
    }
     
    //Method #2 (Service)
    public String systemInfo()
    {
       get_name();
       get_purpose();
    return systemInfo();
    }
     
     
    //Method #3 (Service)
     
     
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Body Systems Class

    Your code indentation is weird when it exists and annoying when it doesn't.

    Naming of the accessors you've written is non-standard. Were you taught to use the 'get_name' naming model? You haven't written any mutator (setter) methods, except (maybe) whatSystem().

    The method below has problems. You may discover them when you try to test it, but you should see the errors if you simply trace the logic in your head:
    	//Method #2 (Service)
    	public String systemInfo()
    	{
    		get_name();
    		get_purpose();
    		return systemInfo();
    	}

    The whatSystem() method: You should provide a better comment that describes what you think this method does for the class. Once you describe it, I think you'll see that it could have a better name that reflects what it does.

    The subject of your class is not my area, but I see some difficulties. You listed the possible systems in your whatSystem() method, so I'm curious, what/how many "organs" will be present in the "Muscular System"? And another concern is, how will you list or name the multiple organs involved in some of the systems? You might consider rethinking your class to describe completely just one of the body systems rather than a single class that can describe them all, which I suspect is not reasonable.

  3. #3
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Body Systems Class

    Body Systems Class

    Duplicate post
    Improving the world one idiot at a time!

Similar Threads

  1. how to get ip address of systems in multicasting environment..??
    By omesh kumar in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 11th, 2013, 12:38 PM
  2. Program won't work on all operation systems
    By 123099 in forum AWT / Java Swing
    Replies: 8
    Last Post: July 18th, 2011, 05:11 PM
  3. Run 2 systems command in applet, how?
    By bulgin in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 8th, 2010, 03:11 PM
  4. Code wise working of Computer Algebra Systems
    By helloworld922 in forum Java Theory & Questions
    Replies: 1
    Last Post: July 7th, 2009, 07:45 AM