#Generic Shape Comparing

1 messages · Page 1 of 1 (latest)

rapid hamlet
#

So I am just having issues for some reason with when and how to properly create my shapes with Generics to utilize a comparing method. I already got a good grasp on the idea with creating the shapes and the "compareTo" generic file. But when I look into other ways to implement it through other sources, all the sources I could find weren't really helpful, just talking about how to manually call them and to create the objects, which is not what I want to do. I want to be able to get input from a user, unable to know what the shapes are and then compare according to what the two shapes are.

jovial juncoBOT
#

<@&987246399047479336> please have a look, thanks.

jovial juncoBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

rapid hamlet
#

This is the code currently I'm using for the call, but it just doesn't work because the program wont know after the if else statements, which shape to do.

if (shape1.equals("Circle")){
   Circle circle1 = new Circle(convertRadius1);
} else if (shape1.equals("Rectangle")){
   Rectangle rectangle1 = new Rectangle(convertWidth1, convertHeight1);
 }
if (shape2.equals("Circle")){
   Circle circle2 = new Circle(convertRadius2);
} else if (shape2.equals("Rectangle")){
   Rectangle rectangle1 = new Rectangle(convertWidth2, convertHeight2);
}
jovial juncoBOT
# rapid hamlet This is the code currently I'm using for the call, but it just doesn't work beca...

Detected code, here are some useful tools:

Formatted code
if (shape1.equals("Circle")) {
  Circle circle1 = new Circle(convertRadius1);
}
else if (shape1.equals("Rectangle")) {
  Rectangle rectangle1 = new Rectangle(convertWidth1, convertHeight1);
}
if (shape2.equals("Circle")) {
  Circle circle2 = new Circle(convertRadius2);
}
else if (shape2.equals("Rectangle")) {
  Rectangle rectangle1 = new Rectangle(convertWidth2, convertHeight2);
}
keen bluff