Results 1 to 4 of 4
  1. #1
    Austin360 is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Circle, Rectangle, Triangle

    Helllo everyone. I was given an assignment the other day to create some code that has 4 different classes which i have made, in which you have one for a triangle, a circle, and a rectangle. There needs to be arrays of up to five bins to hold the info for the created shapes. The instances have to be private, leading to needing getters to retrieve the information. As well, in each class there needs to be methods to move the shape vertically, horizontially, to get the area, the perimeter, and as well relate the different shapes. All is started by the user entering a string of
    For triangle - T x1 y1 x2 y2 x3 y3
    For circle - C x y Radius
    For rectangle - R x y Height Width
    the relation - T/R/C which number shape to T/R/C and which number shape
    move horzontially - T/R/C which number shape how much
    move vertically - T/R/C which number shape how much
    exit program - x
    I have the classes made and the code that creates the shapes and gets the area and perimeter. I am just kinda confused on where to include the arrays and put in the getter methods and as well making the strings to transfer into the code. Any help on some ideas of a direction to go would be very helpful thanks.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Circle, Rectangle, Triangle

    Sounds like the arrays and getter methods should be members of your various shape classes. Getting the input from the user should happen inside a main "driver" class, perhaps the main method itself.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Austin360 is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: Circle, Rectangle, Triangle

    I guess the biggest thing that I am confused on is how to take the string and convert that input into usable values for the constructor to create the shape of those values.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Circle, Rectangle, Triangle

    Have a look at the String class for handy methods on splitting a String up into separate pieces. Then have a look at the Integer class for a handy method on converting from a String to an int. The API is your best friend: Java Platform SE 6
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Perimeter of a Triangle and Circle Program
    By Zora in forum New To Java
    Replies: 7
    Last Post: 10-13-2011, 03:43 AM
  2. Replies: 6
    Last Post: 11-30-2010, 11:29 PM
  3. Replies: 3
    Last Post: 11-22-2009, 08:08 AM
  4. problem with adding circle and rectangle
    By nicnicnic in forum Java 2D
    Replies: 3
    Last Post: 11-16-2009, 06:13 PM
  5. how to add a circle or rectangle in a jtextarea
    By nicnicnic in forum Java 2D
    Replies: 10
    Last Post: 10-17-2009, 04:09 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
  •