Untitled

mail@pastecode.io avatar
unknown
javascript
a month ago
2.3 kB
3
Indexable
Never
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class UbarApp {
    private Map<String, User> users;
    private Map<String, Event> events;

    public UbarApp() {
        users = new HashMap<>();
        events = new HashMap<>();
    }

    public void registerUser(String username, String email) {
        User user = new User(username, email);
        users.put(username, user);
    }

    public void createEvent(String title, String location, String dateTime) {
        Event event = new Event(title, location, dateTime);
        events.put(title, event);
    }

    public void followUser(String followerUsername, String followedUsername) {
        User follower = users.get(followerUsername);
        User followed = users.get(followedUsername);
        follower.followUser(followed);
    }

    public void joinEvent(String username, String eventTitle) {
        User user = users.get(username);
        Event event = events.get(eventTitle);
        event.addParticipant(user);
    }

    public void postInterestInEvent(String username, String eventTitle) {
        User user = users.get(username);
        Event event = events.get(eventTitle);
        event.addInterested(user);
    }
}

class User {
    private String username;
    private String email;
    private List<User> followedUsers;

    public User(String username, String email) {
        this.username = username;
        this.email = email;
        followedUsers = new ArrayList<>();
    }

    public void followUser(User user) {
        followedUsers.add(user);
    }
}

class Event {
    private String title;
    private String location;
    private String dateTime;
    private List<User> participants;
    private List<User> interested;

    public Event(String title, String location, String dateTime) {
        this.title = title;
        this.location = location;
        this.dateTime = dateTime;
        participants = new ArrayList<>();
        interested = new ArrayList<>();
    }

    public void addParticipant(User user) {
        participants.add(user);
    }

    public void addInterested(User user) {
        interested.add(user);
    }
}
Leave a Comment