Object-oriented Design: Dropbox invite system

Design a Dropbox invite system (refer other guys to join and get more space) 
Assume whats required and design.

 1 First we have the user - this is for an existing user

 2 

 3 

 4 class User {

 5     //Basic information

 6     int      id;

 7     String name;

 8     String email;

 9      

10     /* total space -- need to add more information about the account 

11           but this is enough for this question (available, max, etc)

12         */

13     int space;

14     int add_space(int amount) {...}

15 }

16 Second we need something to represent an invitation

17 

18 

19 class Invite {

20       String email; //email of the person being invited

21       int    id;    //id of the user who invited him   

22       

23       Date   sent_date; //These 2 will allow the system to

24       boolean status;   //track the invite status and send

25                         //automatic reminders

26 }

27 Third there needs to be a system to manage all of this

28 

29 

30 class Dropbox {

31       map<int, User> users;   //all the users

32       ArrayList<Invite> invites; //all invitations sent

33 

34       //sends an invite to the email inputed by the user

35       //and adds a new Invite to the invites ArrayList

36       void sendInvite(User from, String to) {...}

37 

38       //When the invited party accepts the invitation

39       //this function is triggered and: 

40       //1. Creates a new User and adds to users.

41       //2. Finds the user that invited him from the invites list

42       //   (according to email and id) and calls add_space

43       void accept(String email) {...}          

44 }

 

你可能感兴趣的:(Dropbox)