Design a Dating System

Design a simple dating system like Tinder with the following features: Register a user with their gender, age, preferences, and interests. Find matching users according to their preferred gender, preferred age range, and common interests. Implement the Tinder class: Tinder() Initializes the object. void signup(int userId, int gender, int preferredGender, int age, int minPreferredAge, int maxPreferredAge, List<String> interests) Registers a user with the given attributes. List<Integer> getMatches(int userId) Returns the...

周六 · 2024-12-07 · 3 分钟 · Yuechen

Java中的注解 (Annotation)

Java 的 注解(Annotation) 是一种用于元编程的工具,它为 Java 程序员提供了一种将元信息嵌入到代码中的方式。通过注解,开发者可以在编译时或运行...

周日 · 2024-12-01 · 6 分钟 · Yuechen

Design Facebook

Design a system like Facebook with the following features: A user can write a post. Two users can become friends with each other. Users can see all the posts written by their friends. Implement the Facebook class: Facebook() Initializes the object. void writePost(int userId, String postContent) The user with id userId writes a post with the content postContent. void addFriend(int user1, int user2) user1 and user2 become friends with each...

周六 · 2024-11-30 · 2 分钟 · Yuechen

Design Whatsapp

Design a system like Whatsapp with the following features: Send a message to a user. Create a group with some initial users. Add more users to a group. Send a message to a group. Get messages for a user. Implement the WhatsApp class: WhatsApp() Initializes the object. void sendMessage(int toUser, String message) Sends a personal message with the text message to the user with id: toUser. int createGroup(int[] initialUsers) Creates a new group that initially contains users whose ids are in the list initialUsers, and the group id is returned....

周日 · 2024-11-24 · 5 分钟 · Yuechen

图床服务器搭建

GitHub Pages 图床使用教程 GitHub Pages 可以作为图床使用,适合存储静态文件(如 .jpg、.png、.gif 格式)。 创建 GitHub 账户: 如果还没有账户,访问 GitHub 注册一个。 创...

周日 · 2024-11-10 · 2 分钟 · Yuechen

代码坏味道之注释 (Comments)

定义 某段代码有大段的注释,这些注释之所以存在是因为代码很糟糕 代码注释错误,或者缺少必要的注释 影响 以注释掩盖了代码坏味道,或者没有正确的注释,...

周日 · 2024-10-13 · 2 分钟 · Yuechen

代码坏味道之被拒绝的遗赠 (Refused Bequest)

定义 对于某个子类,它只想继承基类的部分函数和数据,不需要基类提供的全部内容, 这些不需要的内容就成为了子类的负担 影响 这种坏味道通常影响并不大,...

周日 · 2024-10-13 · 6 分钟 · Yuechen

代码坏味道之纯稚的数据类 (Data Class)

定义 DataClass是指:它们拥有一些字段,以及用于访问(读写)这些字段的函数,除此之外一无长物。 这样的类只是一种不会说话的数据容器。 影响...

周日 · 2024-10-13 · 4 分钟 · Yuechen