Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit e354d34

Browse files
committed
🎉 Hello SomeUtils!
0 parents  commit e354d34

File tree

4 files changed

+154
-0
lines changed

4 files changed

+154
-0
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 JumperBot_
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# SomeUtils
2+
3+
### **"Some" Utilities you can use for your projects "*freely*"!**
4+
5+
---
6+
7+
**Community Contribution** is *welcome* in this repository.
8+
9+
You may use anything in this repository for *personal use*.
10+
11+
If not for *personal use*, you may still use this but your program must include the <a href="./LICENSE">license</a>.
12+
13+
---
14+
15+
## **How To Use:**
16+
17+
**Option 1:**
18+
19+
```shell
20+
git clone https://github.com/JumperBot/SomeUtils.git
21+
cp ~/SomeUtils/SomeUtils/LICENSE /Your/Project/Before/src/Directory/
22+
cp ~/SomeUtils/SomeUtils/NeededUtility/NeededUtility.class /Your/Project/Before/src/Directory/
23+
```
24+
25+
**Option 2:**
26+
- Go to: https://github.com/JumperBot/SomeUtils .
27+
- Click the "Code" drop-down button.
28+
- Click on the "Download ZIP button".
29+
- Get what you want and what you need (including the license).
30+
31+
**Option 3:**
32+
- Do what you want just to get access to this.
33+
34+
After getting access to **"the"** code, import using:
35+
36+
```Java
37+
import SomeUtils.WhatYouNeed.WhatYouNeed;
38+
```
39+
40+
---
41+
42+
## But I Can't Find What I Need!
43+
44+
**Option 1:**
45+
- Be disappointed.
46+
- Leave the website.
47+
- Be selfish.
48+
- Write the code.
49+
- Keep it for yourself.
50+
- Go back to **"work"**.
51+
52+
**Option 2**
53+
- Be a *"good"* community member.
54+
- Clone the repository.
55+
- Write the code.
56+
- Initiate a Pull Request.
57+
- Feel good about it.
58+
- Go back to *"work"*.
2.07 KB
Binary file not shown.
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package SomeUtils.ProgressBar;
2+
3+
import java.lang.StringBuilder;
4+
5+
public class ProgressBar{
6+
//Demo, can be removed if you want to!
7+
public static void main(String[]a){
8+
final ProgressBar progress=new ProgressBar(100);
9+
progress.printBar();
10+
for(int i=0;i<100;i++){
11+
progress.addValue();
12+
progress.printBar();
13+
try{
14+
java.lang.Thread.sleep(100);
15+
}catch(Exception e){}
16+
}
17+
}
18+
//The actual class, don't remove! (Please)
19+
final int[] values={0, 0};
20+
public ProgressBar(){
21+
//SUFFER
22+
}
23+
public ProgressBar(final int maxVal){
24+
values[0]=0;
25+
values[1]=maxVal;
26+
}
27+
public ProgressBar(final int minVal, final int maxVal){
28+
values[0]=minVal;
29+
values[1]=maxVal;
30+
}
31+
public int getValue(){
32+
return values[0];
33+
}
34+
public int getMaxValue(){
35+
return values[1];
36+
}
37+
public int[] getValues(){
38+
return values;
39+
}
40+
public void setValue(final int newValue){
41+
values[0]=newValue;
42+
}
43+
public void addValue(){
44+
values[0]++;
45+
}
46+
public void deductValue(){
47+
values[0]--;
48+
}
49+
final String emptyBar=" ";
50+
final String fullBar="====================";
51+
public void printBar(){
52+
//Percentage need not to be very accurate.
53+
//Ternary statement didn't worked, don't know why.
54+
final int percentage=(int)(
55+
(values[0]>=values[1])?100:
56+
(values[0]*100)/values[1]
57+
);
58+
final int barShown=(int)(percentage/5);
59+
System.out.print(
60+
new StringBuilder("[")
61+
.append(percentage)
62+
.append("%][")
63+
.append( fullBar.substring(0, barShown))
64+
.append(emptyBar.substring(barShown))
65+
.append("][")
66+
.append(values[0])
67+
.append("/")
68+
.append(values[1])
69+
.append("]\r")
70+
.toString()
71+
);
72+
if(percentage==100)
73+
System.out.println();
74+
}
75+
}

0 commit comments

Comments
 (0)