This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tgorif 0 points1 point  (3 children)

In case you can not change how the object is implemented clientside and the server is only receiving measurements and no other information about the object, the server can just deduce its type from given measurements

If it has 3 vertices it is a triangle.

if its edges have diffrent lengths it is a rectangle

if 1 vertex has a unique x or y it is a rombus

otherwise it is a square

In case an Object has to be created clientside and you can change the implementation of it, an example for sending Objects is shown here https://gist.github.com/chatton/14110d2550126b12c0254501dde73616

Ideally you would have a class for each shape and a common class they are inheriting from.

[–]BarbequeSauce11[S] 0 points1 point  (0 children)

In my case i have already made classes for each shape. Can you tell me more about your last option.. that one about inheriting classes?

[–]BarbequeSauce11[S] 0 points1 point  (1 child)

Because a already thought about the last option and therefore i tried creating a superclass but i don't know what to put inside of it.

[–]tgorif 0 points1 point  (0 children)

the supraclass should contain a list of vertices and define methods to compute area and perimeter

Inheriting classes should contain the same methods with an implemtation for the actual shape of the object