Communication between two different classes

i’m planning to build a comment system, but don’t know how to go about it. I have the following thought out.

  1. there will be users and comments class

  2. There will be three categories of users; normal users, moderators and admins. All will have varying level of privileges. This users class will have a single property; name.

  3. There will also be a method that will get comments belonging a particular name
    a. The comment argument in the above method will be the message property in the comment class

  4. The comment class class will have three properties; author, message and repliedTo (if comment is a reply to another comment).
    a. the author in the comment class will be the name property in the user class.

My question is How do I make these two classes communicate with each other?

You can make a third class called Chat that holds main functionality and create instances of those user classes there. Depends what lib you are using, is it with React? is backend in node?

For messages I would probably just use a simple object, since its 3 props with no special functionality.

backend is Node, no frontend library.

Could use to set up a basic chat, then go from there.