Skip to content

CS 180 Capstone Project - To design and implement a limited form of social network application.

Notifications You must be signed in to change notification settings

CS180-022-2/Project_5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project 5 Option 2, Group 022-2

CS 180 Capstone Project

To design and implement a limited form of social network application.


This README file has to be submitted under the Documentation of our project.

This document will include the following for each class:

  1. A detailed description.
  2. Descriptions of the testing done on that class. For GUI testing, provide step-by-step guidance on the tests performed.

In situation where the user needs to select a line and engage action, the below prompt will appear if they don't

selectLine

In situation where the user needs to input info for account or profile, something like the below prompt will appear if they input something invalid

rerror1

Instructions

Run the program by first running profileServer.java, then profileClient.java. The login GUI should pop up if everything is working. If profileClient.java cannot connect, check the socket id and port numbers.

Known Issues

JTable does not update itself unless the user performs any functionality. Users may need to press the back button to "Refresh" the frame in order to see new changes.

AccountMenuFrame Class

Description

This is a class representing the frame that gives users the option to either edit, or delete their accounts. The above mentioned functions are accessed through the use of buttons.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

GUI

Run() method

This method sets up the appearance of the frame

accountMenuFrame

  • Pressing "Edit Acoount" button will take the user to EditProfileFrame
  • Pressing "Back" button will take the user to AccountProfileFrame
  • Pressing "Delete Account" button will prompt this message below and delete the profile

deleteProfile

#### Class Documentation ##### public AccountMenuFrame(Socket socket, String userId) Constructor The constructor of AccountMenuFrame which uses two parameters : socket, the socket that connect this local machine with the server, and userId, the userId of the login user.

AccountProfileFrame Class

Description

A class representing the frame that serves as an intermediary for creation, edition, and deletion of both user account and profile. When the user wants to edit or delete their account, they can click "Account" button and vice versa for their profile.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

GUI

Run() method

This method sets up the appearance of the frame

accountProfileFrame

  • Pressing "Profile" button will take the user to ProfileMenuFrame
  • Pressing "Back" button will take the user to UserFrame
  • Pressing "Account" button will take the user to AccountMenuFrame

Class Documentation

public AccountProfileFrame(Socket socket, String userId) Constructor

The constructor of AccountMenuFrame which uses two parameters : socket, the socket that connects this local machine with the server, and userId, the userId of the login user.

AddFriendFrame Class

Description

A class representing the frame to send friend requests to another users, view a list of all the application's users, search a specific user among all the application's users, view the requested friend list and the pending friend list. Three JScrollPane, each contains a JTable. The center one would have a table that contains all users where you can choose users to send friend request. The left one would have a table that record all users which you have sent request to but not get respond. You can choose to resend request. The right one would have a table that contains all users which have sent you a request. You can either accept or deny

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

GUI

Run() method

This method set up the appearance of the frame

addFriendFrame

  • Selecting "viewProfile" button will take the user to ProfileDisplayFrame of that user
  • Pressing "Back" button will take the user to UserFrame
  • Pressing "sendFriendRequest" button will make current user appear on the pending list of the requested user, while the requested user will apeear on current user's requested list
  • Pressing "accept" button will make accepted user appear on current user's friendlist
  • Pressing "deny" button will make the denied user disappear from the pending list
  • Pressing "resendRequest" button will make current user reappear on requested user's pending list

Step by step Test

Pending Table

pendingDerek

If Deny

pendingDeny

If Accept

pendingAccept - Copy

This prompt comes up

acceptSuccess - Copy

Derek will be added to friend list

afterafteraccept

Class Documentation

public AddFriendFrame(Socket socket, String userId) Constructor

The constructor so that socket and the login userId can be passed. Two parameters: socket and userId.

updateAllUserModel() method

Communicates with the server to get most updated user list

updatePendingModel()

Communicates with the server to get the updated user info in the pending list

updateRequestModel() method

Communicates with the server to get the updated user info in the request list

updateAll() method

Updates the data by changing the model of all three tables. Resets the rowSorter to make sure the search bar keep working. Then repaints the JFrame addFriendFrame

EditAccountFrame Class

Description

A class representing the frame to edit the user account details. Users can change their name, email address, and password but not the user ID. All the changed account details must conform to the respective validation rules.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

GUI

Run() method

This method sets up the appearance of the frame

editAccountFrame

  • Pressing "editAccountButton" button will reset user's account info with input
  • Pressing "Back" button will take the user to AccountMenuFrame

Step by step Test

Let's delete Joshua's account

First login in as Joshua, id = joshua, password = Cs180===

LoginAsJoshua

LoginAsJoshuaandDELETE

Delete successfully !

LoginASJOSHUAandDELETESUcceses

Using the same userID and password, we can't no longer login as Joshua

LoginasJOshuaNOWFAIL

Let's edit Leo's account

His account before edit was passowrd: Cs180=== Name: Leo Li email: [email protected]

LeoLogIn

Edit leo's account info as: password: Cs280=== Name: Leo La email: [email protected]

LeoEditingAccount

Now we see the changes as another user

LeoaddfriendFrame

Leo has to login with password Cs280=== instead of Cs180=== from now on

LeoLoginwithcs280

#### Class Documentation ##### public EditAccountFrame(Socket socket, String userId) Constructor The constructor of UserFrame which uses two parameters : socket, the socket that connects this local machine with the server, and userId, the userId of the login user. ##### contentCheck() method Checks inserted information to make sure it doesn't contain forbidden characters.

EditProfileFrame Class

Description

A class representing the frame to edit the details of the user profile. All the changed profile details must conform to the respective validation rules.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

GUI

Run() method

This method sets up the appearance of the frame

profileFrame

  • Pressing "editProfileButton" button will reset user's profile info with input
  • Pressing "Back" button will take the user to ProfileMenuFrame

Step by step Test

Test by editing Derek's profile which was blank

editProfileAsDerek

Viewing Derek's profile as another user

ViewDerekProfile

It's just as how Derek edited it

profileDisplayFrame

Let's delete Derek's profile now

deleteProfile

DeleteDerekProfile

Looking at Derek's profile as another user, Derek's profile became blank again

DeleteAfterDerekProfiel

#### Class Documentation ##### public EditProfileFrame(Socket socket, String userId) Constructor The constructor of EditProfileFrame which uses two parameters : socket, the socket that connects this local machine with the server, and userId, the userId of the login user. ##### contentCheck() method Checks inserted information to make sure it doesn't contain forbidden characters and that it isn't empty.

LoginFrame Class

Description

A class representing the frame that will appear at the very beginning when the user starts the application. Users will be able to login using their User ID and Password. Note that users need to first register to be able to log in.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

GUI

Run() method

This method sets up the appearance of the frame

loginFrame

  • Pressing "loginButton" button will take the user to UserFrame if login was succesful, if not below

loginFailure

loginSuccessful

  • Pressing "registerButton" button will take the user to RegisterFrame

Class documentation

public LoginFrame(Socket socket) Constructor

The constructor of LoginFrame which uses one parameter : socket, the socket that connects this local machine with the server.

Profile Class

Description

A class representing the profile of the registered user.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

Class Documentation

public Profile(String phoneNumber, String relationship, String gender, String currentOccupation, String interest, String aboutMe) Constructor

Constructor for the Profile class. Creates a new Profile with the provided data.

Getter & Setter methods

Class includes getters and setters for each of the fields.

ProfileClient Class

Description

A class representing the client-side of our application. This class includes the main method and invokes the Login frame of our application when begin.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

Class Documentation

main method

The main method of our program. Initializes the hostname with "localhost" and port number with 1112. Starts by invoking a LoginFrame in the Event Dispatch Thread.

ProfileDisplayFrame Class

Description

A class representing the profile details of the user in a separate frame. Profile details include: Phone Number, Current Occupation, About Me, Interests, Gender, and Relationship Status

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

GUI

Run() method

This method sets up the appearance of the frame

profileDisplayFrame

  • Pressing "Back" button will take the user to UserFrame or AddFriendFrame depending the current frame the user's at

Class Documentation

public ProfileDisplayFrame(Socket socket, String viewerId, String profileOwnerId, String tracker) Constructor

The constructor of ProfileDisplayFrame which uses four parameters : socket, the socket that connects this local machine with the server, viewerId, the userId of the viewer, profileOwnerId, the userId of the owner of this profile, and tracker, the tracker that tracks the user.

ProfileMenuFrame Class

Description

A class representing the frame that gives users the option to either create, edit, or delete their profiles. This class cts as a hub hosting buttons that leads users to other frames that carry out creation, edition, or deletion.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

GUI

Run() method

This method set up the appearance of the frame

profileMenuFrame

  • Pressing "Back" button will take the user to AccountProfileFrame
  • Pressing "editProfileButton" button will take the user to EditProfileFrame
  • Pressing "deleteProfileButton" button will prompt a comfirmation message, if the user chose yes then its profile info will be reset to blank

deleteProfile

Delete empty profile Test Step by step

Jason has an empty profile

JasonProfile

Let's delete the empty profile

JasonProfile2

An error occurred, we can't delete an empty profile

JasonProfile3

Class Documentation

public ProfileMenuFrame(Socket socket, String userId) Constructor

The constructor of EditProfileFrame which uses two parameters : socket, the socket that connects this local machine with the server, and userId, the userId of the login user.

ProfileServer Class

Description

A class representing the backend server-side of our application. All the processing of data, connecting to the client, and file I/O happens here.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

Class Documentation

public ProfileServer(Socket socket) Constructor

The constructor of ProfileServer which uses one parameter : socket, the socket that connects this computer connect with the server.

login() method

Check the username and password to see if the user logs in. Returns true if the user entered username and password are correct, false otherwise.

getProfile() method

Returns the Profile that matches with the given userId parameter

setUserProfile() method

Sets the userProfile up with the inserted userId. Return true if setup is successful, false if userId is not found in the database.

requestFriend() method

Sends out a friend request to the reciever using userId as a guide. Returns "RequestSuccess" if the request was successful; "Already friend!" if in each other 's friendList already; "Already requested!" if requested user is in requester's requested list; "Already being requested!" if the requested user has already sent a request to requester.

deleteFriend() method

Deletes a friend in user's friend's list and removes user from the deleted friend's friends list. Return true if the deletion is successful, false otherwise.

uniquePhoneNoCheck() method

Checks to make sure every phone number registered is unique. Returns true if the phone number is unique, false if it has been used.

uniqueIdCheck() method

Checks if the given parameter userId is unique in the database. Returns true if userId is unique, false otherwise

acceptFriend() method

Accepts the request in pending list, add to each other's friendList, and remove from pending and requested list. Return "AcceptSuccess" if there is an request and are accepted successfully; "No request found" if there are no request; "No such user found" if Ids cannot be found.

denyFriend() method

Denies the request in pending list and deletes history in pending and requested list. Return "DenySuccess" if there is an request and deny successfully; "No request found" if there are no request; "No such user found" if Ids cannot be found.

resendRequest() method

Checks if the request has been sent. If not, resend request; if sent, asks the user to be more patient. Return "RequestExisted" if the request is in the user's pending list; "ResendSuccess" if there is no request and the request is resend; "No such user found" if Ids cannot be found.

run() method

Starts whenever a new socket is accepted. Creates a printWriter and a bufferedReader. Uses a switch statement to perform different tasks required by the client.

RegisterFrame Class

Description

A class representing the frame that allows the users to register for this application. All users must register before being able to login to the application. All the account details must conform to the respective validation rules.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

GUI

Run() method

This method set up the appearance of the frame

registerFrame

  • Pressing "Back" button will take the user to LoginFrame
  • Pressing "registerButton" button will save the user's input and create a new User object for it if the inputs are valid, if not below

rerror3

rerror4

rerror1

rerror2

#### Class Documentation ##### public RegisterFrame(Socket socket) Constructor The constructor of the RegisterFrame, includes one parameter: socket, the socket that connects this local machine with the server. ##### contentCheck() method Checks the format of text in JTextField and JPasswordField for user id, password, real name, and email. The functionality is implemented using String.matches() method which requires a regex as its parameter. The content has to fully match the regex in order to have boolean correct as true

User Class

Description

A class representing the user who will be registering to use our application.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

Class Documentation

public User(String userId, String password, String name, String email) Constructor

Creates a User object with the specified parameters. Three empty arraylist and a profile with empty string would be constructed/initialized.

Getters & Setters

Class also contains getters and setters for fields userId, password, name, email, friendList, and userProfile.

UserFrame Class

Description

A class representing the frame displaying the friend list of the user in the application. The user is able to see the profile of users in the friend list and delete them from the friend list. Use a JTable to display all your friends and a search bar to find certain friends.

Testing

  1. Tested that the class exists and inherits or implement the correct classes
  2. Tested that all fields exist, and are of correct type and modifiers
  3. Tested that all methods exist, and have the correct return type and modifiers
  4. Two implementation tests to test if each method work with correct input and fails with incorrect input.

GUI

Run() method

This method set up the appearance of the frame

userFrame

  • Pressing "Back" button will take the user to LoginFrame
  • Pressing "add" button will take the user to AddFriendFrame
  • Pressing "account" button will take the user to AccountProfileFrame

Step by step Test

Search Bar Testing

Before search

UserBeforeSearch

After search, the id that matches remains, the rest disappear

UserAfterSearch

Delete Friend Test step by step

Log in as Derek and delete Jason

DeleteFriend1

Jason disappears from friendlist DeleteFriend2

Derek disappears from Jason's friendlist DeleteFriend3

Class Documentation

public UserFrame(Socket socket, String userId) Constructor

The constructor of UserFrame which use two parameters : socket and userId. socket: the socket that connect this computer connect with the server. userId: The userId of the login user

updateModel() method

Communicates with the server and get the updated userInfo in the login user's friendList

About

CS 180 Capstone Project - To design and implement a limited form of social network application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages