Results 1 to 4 of 4
Thread: Circle, Rectangle, Triangle
- 03-08-2012, 05:44 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 3
- Rep Power
- 0
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.
- 03-08-2012, 05:46 PM #2
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 - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
- 03-08-2012, 05:51 PM #3
Member
- Join Date
- Mar 2012
- Posts
- 3
- Rep Power
- 0
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.
- 03-08-2012, 06:19 PM #4
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 - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
Similar Threads
-
Perimeter of a Triangle and Circle Program
By Zora in forum New To JavaReplies: 7Last Post: 10-13-2011, 04:43 AM -
does rectangle contain or overlap another rectangle?
By Xycose in forum New To JavaReplies: 6Last Post: 12-01-2010, 12:29 AM -
how to paint a circle or rectangle in a specify tab of the jtabbedpane ?
By nicnicnic in forum Java 2DReplies: 3Last Post: 11-22-2009, 09:08 AM -
problem with adding circle and rectangle
By nicnicnic in forum Java 2DReplies: 3Last Post: 11-16-2009, 07:13 PM -
how to add a circle or rectangle in a jtextarea
By nicnicnic in forum Java 2DReplies: 10Last Post: 10-17-2009, 05:09 PM
Bookmarks