Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nikhil-jindal12/sortingalgorithms
Contains implementation for a unique form of Case Western Reserve University's campus cash and customized merge sort and quick sort methods.
https://github.com/nikhil-jindal12/sortingalgorithms
java-8 javadoc-documentation merge-sort quick-sort
Last synced: 9 days ago
JSON representation
Contains implementation for a unique form of Case Western Reserve University's campus cash and customized merge sort and quick sort methods.
- Host: GitHub
- URL: https://github.com/nikhil-jindal12/sortingalgorithms
- Owner: nikhil-jindal12
- Created: 2023-11-23T23:23:14.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-22T01:17:17.000Z (about 1 year ago)
- Last Synced: 2024-11-13T04:13:27.839Z (2 months ago)
- Topics: java-8, javadoc-documentation, merge-sort, quick-sort
- Language: Java
- Homepage: https://nikhil-jindal12.github.io/SortingAlgorithms/
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SortingAlgorithms
This repository contains three classes: `Student.java`, `CaseCashSystem.java`, and `CaseCashSystemTest.java`. These files build off of Case Western Reserve University's campus cash which is called CaseCash.
The point of this repository is to implement the following functionalities with the CaseCash plan:
- Transfer of CaseCash from Student A to Student B
- Deposit CaseCash into a Student account
- Withdraw CaseCash
- View student account balance
- Be able to sort students by name and account balance (using different sorting algorithms)----
The `Student.java` class has the following functionalities:
- `int getBalance()` - returns the CaseCash balance the student has in their account
- `void updateBalance(int newAmount)` - updates the CaseCash balance the student has in their account----
The `CaseCashSystem.java` class has the following functionalities:
- `List runSimulation(List commands)` - this parses the commands it is given, calls the respective helper functions, and runs a simulation provided based on the commands it is given (more details regarding the inputs are given below)
- `boolean init(String name, int initialBalance)` - initializes a student with the name and initial CaseCash balance given, returning false if the initial balance is negative or a student with the same name already exists
- `int getBalance(String name)` - returns the balance of a student given their name
- `boolean deposit(Student student, int amount)` - deposits CaseCash to a student's account, returning false if the deposit fails
- `boolean transfer(Student studentA, Student studentB, int amount)` - transfers the amount of CaseCash from studentA to studentB's account, returning false if the transfer was unsuccessful or the amount was negative
- `List sortName()` - returns a list of student's names in alphabetical order using a customized implementation of **merge sort**
- `List sortBalance()` - returns a list of student's name in the order of smallest balance to largest balance in their account using a customized implementation of **quick sort**
- `boolean withdrawal(Student student, int amount)` - removes CaseCash from a student's account, returning false if the transaction will result in a negative balance----
### Inputs
Inputs are given to the simulation in the following format:
- “**INIT**, name, initialBalance”
- “**GET**, name”
- “**TRANSFER**, studentA, studentB, amount”
- “**WITHDRAWAL**, studentA, amount”
- “**DEPOSIT**, studentA, amount”
- “**SORT**, name or balance”Each of the bolded keywords corresponds directly to one of the methods in the `CaseCashSystem.java` class.
Here is an example simulation:
List inputs = [“INIT, Tammy, 200”,
“INIT, Kim, 300”,
“INIT, Quyen, 400”,
“SORT, name”,
“SORT, balance”,
“TRANSFER, Kim, Tammy, 100”,
“SORT, name”,
“SORT, balance”];System.out.println(runSimulation(List inputs))
>>> [“true”,
“true”,
“true”,
“[Kim, Quyen, Tammy]”,
“[Tammy, Kim, Quyen]”,
“true”,
“[Kim, Quyen, Tammy]”,
“[Kim, Tammy, Quyen]”]----
### JUnit Testing
The `CaseCashSystemTest.java` class contains thorough JUnit testing for each of the methods in the `CaseCashSystem.java` class. All of the JUnit tests pass, and therefore the customized implementations of **merge sort** and **quick sort** correctly sort the student's names and balances.