C
C#2y ago
Lazer

✅ Question regarding C# UML diagrams and classes

Hello! Do classes need to have some form of relation in a UML diagram? I'm making Go Fish in VSC, have two classes made, one for the player and one for the deck. While both classes are used in the project's main file, neither class is referenced inside of the other. This leads me to ask if they can be separate on a UML diagram or if it means I need to make a 'game' class to put my main file's process in, while relating the Player and Deck class to it in the diagram. Hope this makes sense, still very new to this. Thanks!
15 Replies
friedice
friedice2y ago
what do you mean by relation?
JakenVeina
JakenVeina2y ago
consumption/inheritance?
Lazer
LazerOP2y ago
Yes, like OOP relations
friedice
friedice2y ago
A dog Is An animal however the dog does not need to hold a rocket launcher unless that's what your game is about but generally you dont need to over complicate things if you dont need to
Lazer
LazerOP2y ago
I think I understand. So I probably don't need to make a class for the game process as a whole then?
friedice
friedice2y ago
what do you mean by that? like a state machine?
Lazer
LazerOP2y ago
I'm not sure what a state machine is. When I look online or at my teacher's example version of another project, there seems to be a class that holds the majority of code, then an instance is made of this 'game' class in the main program.cs file
friedice
friedice2y ago
does it look something like this?
Lazer
LazerOP2y ago
More like this I think (found on google). If I'm right here, the box with "GoFish" is the class that acts as the game's process. it can inherit the other classes but they can't inherit it
Lazer
LazerOP2y ago
So what I'm wondering is if I need to make that or if the classes can just have no relation to anything and be floating Or if I need to make that and make the same in my code instead of just referencing things from both classes in the program.cs
friedice
friedice2y ago
well technically program.cs would be the class that acts as the game's process (assuming your game is a console app) there is no god class like that, you would have to create the game loop that does what you want to manipulate the objects in your games
Lazer
LazerOP2y ago
Ah, yes. I just mean where all program.cs has is something like
using WarCardGame;


Game warCardGame = new Game();
using WarCardGame;


Game warCardGame = new Game();
(example from a diff project) Ah alright Thank you for the help
Florian Voß
Florian Voß2y ago
I condtradict with IceGPT and I think its a very good idea to encapsulate the game in its own type. Program.cs can be seen as a client that only calls what we have. It should stay stupid IMO and not contain thhe logic this is also how we have it in Asp.Net Core for example. Program.cs doesn't contain the code to create and run the webapplication, it only calls it.
Lazer
LazerOP2y ago
Yeah, I read up on it a little more and I agree. Thank you as well!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server