Skip to content

CarterYoo/CS180ProjectRecovery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS180Project

CS 180 Project Team 2

Members:

  • Varun Lanka
  • Sri Pydimarri
  • Yichen Wang
  • Seunghyun Yoo
  • Deeya Prabhu

Project Name: Little Claws

Submissions:

  • Phase 1: Yichen Wang
  • Phase 2: Sriranga Pydimarri

Interfaces:

  • Market.java: Interface containing basic methods which defines the core functionality for the Marketplace class. Contains methods pertaining to the user, items, and balance of the user.

  • SellerRatingManagerInterface.java: Interface containing basic methods which defines the core functionality for the SellerRating class. Contains methods pertaining to the user, items, and balance of the user.

  • ServerInterface.java Interface contains basic methods which define the core functionality for the Server class. Contains methods pertaining to starting and stopping the server, broadcasting and directing messages, adding and removing client, and handling user information through checking and updating added or deleted users as needed.

Classes & Testing:

  • Item.java: Contains the implementation for each item being sold on the marketplace. Stores the item details in the fields: title, description, price, isSold, category, and imagePath. Stores all the features reagarding the items (Cats). => ItemTest.java: The test class creates a new item and checks if it's methods are storing the information correctly.

  • Marketplace.java: Acts as a databse for the entire project, implementing the basic functionality of the entire project by creating the market interface. The class implements both the Market and SellerRatings Interface. Has two fields, one storing all the Items and another storing all the Users. This class handles all the user information and authentication, item transactions, storing and displaying data, and seller ratings. All while ensuring thread safety for multiple transactions. => MarketplaceTest.java: The test class creates a new user and item inorder to test the functionality of the methods. To see if the user authentication works along with the balance and item methods work. In phase 1, our team could not figure out how to fix the Index Out of Bounds error, yet we intend to fix this in Phase 2.

  • SellerRating.java: Contains all the information regarding the seller for the marketplace. Having the fields of the sellerUsername, rating, comment, timestamp, and ratings. Similar to the User.java class it's for the sellers side. Declaring the functionality of the Seller.

  • User.java: Contains the basic information of the buyers for the marketplace. Having the fields of the username, password, and their balance. The class declares the user credentials and balance from transactions. Acts as a manager for the user's account. => UserTest.java: Creates multiple new users with various balances to ensure transactions regarding the user's balance works. Along with seeing if the data is being stored properly in the database.

  • Client.java: Establishes a Transmission Control Protocol (TCP) connection to specified server running on a specific port. After connecting, client allows user to send messages to the server via console input. Responses are received using a separate receiving thread. Client prints both of the sent and received messages for clarity. Disconnection is handled through the closeConnection method, and automatically shuts down the connection upon error or when the user decides to exit. => ClientTest.java: Simulates server behavior to verify that client is able to successfully connect, send, and receive messages. Handles edge cases like server unavailability or disconnection, ensuring client may handle these cases without the system crashing.

  • ClientHandler.java: Manages communication between the server an a single client by running on its own thread. Sets up input and output streams, handling sending messages, and closes the connection gracefully when needed. Right now, the server prints client input into the console (requirement for Phase 2). In the next phase, our team will further develop our process commands like LOGIN, REGISTER, BROADCAST, and DM using the commented-out processRequest() method. We commented out the code because it is still being refined. Once fully implemented, it will allow the server to dynamically respond to client actions. => ClientTest.java: Designed to simulate and verify the behavior of the Client class. Checks whether the client is able to successfully connect to the server, send messages, and receive responses. It helps ensure that the core client-server communication works as expected, prior to implementing more advanced features in Phase 3.

  • DatabaseManager.java: Handles all interactions with the user database for the server. Reads and writes user credentials and balances to a file, allowing the server to validate logins and register new users. The class ensures that data is stored persistently and can be accessed reliably across sections. Methods like isValidLogin, userExists, and registerUser, manage the process of user authentication and account creation, which are essential management features for our program. This class forms the backend support for login and registration features that are goign to be integrated in Phase 3. => DatabaseManagerTest.java: Verifies the accuracy of database operations such as user login validation, existence in the system, and registration. Ensures that users can successfully be added and that duplicate registrations are handled properly. Checks the validity of credentials, rejecting invalid ones, confirming the user authentication process.

  • Server.java: Sets up and manages a multithreaded server that handles client connections, authentication, messaging, and user account operations. Uses a ServerSocket to listen for incoming client connections and spawns a new ClientHandler thread for each user. Server supports broadcasting messages to all clients, direct messaging between users, and basic account management like registration, login validation, and deletion. Interacts with the DatabaseManager to persist user data and maintain system state. => ServerTest.java: confirms that client connections are accepted, users can be authenticated and registered properly, and that server messages (broadcast and direct) are sent reliably under concurrent usage.

Exceptions:

  • InsufficientBalanceException.java: Returns a custom error message if the user doesn't have enough money in their account and goes to purchase an item.

  • InvalidLoginException.java: Returns a custom error message if the user's account doesn't exist or if their password is incorrect.

  • ItemNotAvailableException.java: Returns a custom error message if the item the user is trying to access doesn't exist or if it's already sold.

  • UserAlreadyExistsException.java: Returns a custom error message if the user is trying to create an account with a username that is already taken.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages