Skip to content

Commit

Permalink
Make randomizing more complex
Browse files Browse the repository at this point in the history
  • Loading branch information
Tech-FZ committed Sep 18, 2022
1 parent e314597 commit d4efb1f
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 17 deletions.
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,28 @@ HDD: 2 MB free disk space (really small, right?)

⁵ The official Oracle binaries are not free for anything but development and testing purposes. Using the Adoptium Temurin binaries is recommended. You can get them here: https://adoptium.net/de/

# Installation
## Versioning scheme

Updated: 18th September, 2022 with 2022.9.0

A versioning scheme can be difficult. To help, I decided to explain. Generally, it is listed as yyyy.m.r with yyyy being the year a version was released, m being the month a version was released and r being the release number within a month.

### Examples

| Version | Interprete as |
| ------- | ------------- |
| 2022.9.0 | The first release in September 2022 |
| 2039.11.7 | The eigth release in November 2039 |
| 2012.2.19 | The 20th release in February 2012 |

## Installation
Just download the JAR file and run the program after installing Java. Easy, right?

# Building
## Building
Just download the source code and run Eclipse. I recommend beginning a new project and copy the source code into new files. Then you can run it. If it works, right click on src, then choose Export, expand Java, click on Runnable JAR file, follow the instructions and - done!

# Contribution
## Contribution
You must open a new issue before making contributions. But then, feel free to apply your plans to the program.

# Forking
## Forking
This program is licensed under MIT. That means you can fork it and make it your own with little restrictions. Isn't that cool?
Binary file modified bin/randopackage/RandochooseMain$1.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain$2.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain$3.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain$4.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain$5.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain$6.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseUpdateStageTwo.class
Binary file not shown.
7 changes: 7 additions & 0 deletions doc/Changelog English.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Randochoose 2022.9.0
- Not yet complete
- Randochoose 0.2.x and older just picked from the candidates you typed in. That wasn't the best solution - that's why I'm happy to announce that the randomizing algorithm is a bit more complex now. Starting with this version of Randochoose, the list will be shuffled as many times as the number of your candidates before they are chosen.
- Also, the versioning scheme has been changed from x.y.z (0.2.x and older) to y.m.r (like 2022.9.0, 2022.9.1 etc.). y is the year, m the month and r tells you if it is the first/second/... release within a month.
- README.md has been corrected and updated.
- The updater only checks the version code from now on.

Randochoose 0.2.4 Alpha
- Completion: 18th September, 2022
- This is an emergency update - I forgot to update the maximum number of indexes in the second stage of the updater. That causes 0.2.3 to not notify about updates.
Expand Down
44 changes: 32 additions & 12 deletions src/randopackage/RandochooseMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import java.awt.event.*;
import java.io.File;
import java.util.concurrent.*;
import java.util.*;

public class RandochooseMain {

public static int majorVer = 0;
public static int minorVer1 = 2;
public static int minorVer2 = 4;
public static int verCode = 7;
public static int majorVer = 2022;
public static int minorVer1 = 9;
public static int minorVer2 = 0;
public static int verCode = 8;

public static void main(String[] args) {
String link = "https://raw.githubusercontent.com/Tech-FZ/randochoose/main/vercheck.rdc";
Expand All @@ -22,14 +23,15 @@ public static void main(String[] args) {
JFrame mainFrame = new JFrame();
mainFrame.setTitle("Randochoose");
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.setSize(500, 300);
mainFrame.setSize(800, 600);
mainFrame.setMinimumSize(mainFrame.getSize());
mainFrame.setLocationRelativeTo(null);

JPanel mainPanel = new JPanel(new GridLayout(4, 2, 10, 10));
JPanel mainPanel = new JPanel(new GridLayout(3, 0, 10, 10));

JLabel alphaLabel = new JLabel("This program is an alpha! Major issues expected.");
/*JLabel alphaLabel = new JLabel("This program is an alpha! Major issues expected.");
alphaLabel.setFont(new Font("Arial", 0, 14));
mainPanel.add(alphaLabel);
mainPanel.add(alphaLabel);*/

JLabel noticeLabel = new JLabel("One line is one candidate!");
noticeLabel.setFont(new Font("Arial", 0, 20));
Expand All @@ -48,7 +50,7 @@ public static void main(String[] args) {

mainPanel.add(textPanel);

JPanel btnPanel = new JPanel(new GridLayout(1, 3, 10, 10));
JPanel btnPanel = new JPanel(new GridLayout(1, 2, 10, 10));

JButton chooseCandidateBtn = new JButton("Choose!");
chooseCandidateBtn.setFont(new Font("Arial", 0, 14));
Expand Down Expand Up @@ -134,10 +136,28 @@ public void actionPerformed(ActionEvent arg0) {
noEntryDialog.setVisible(true);
}

public static void randomizedChoice(String[] candidates) {
int i = candidates.length;
public static void randomizedChoice(String[] candidates) {
for (int h = 0; h < candidates.length; h++) {
// Creating a object for Random class
Random r = new Random();

// Start from the last element and swap one by one. We don't
// need to run for the first element that's why i > 0
for (int i = candidates.length - 1; i > 0; i--) {
// Pick a random index from 0 to i
int j = r.nextInt(i);

// Swap arr[i] with the element at random index
String temp = candidates[i];
candidates[i] = candidates[j];
candidates[j] = temp;
}
}

// Prints the random array
System.out.println(Arrays.toString(candidates));

int randomizedInt = ThreadLocalRandom.current().nextInt(0, i);
int randomizedInt = ThreadLocalRandom.current().nextInt(0, candidates.length);
String chosenCandidate = candidates[randomizedInt];

JDialog noEntryDialog = new JDialog();
Expand Down
2 changes: 1 addition & 1 deletion src/randopackage/RandochooseUpdateStageTwo.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void checkStage(int majorVer, int minorVer1, int minorVer2, int ve
i++;
}

if (minorVer2 < newestVerInt[2] || minorVer1 < newestVerInt[1] || majorVer < newestVerInt[0] || verCode < newestVerInt[3]) {
if (verCode < newestVerInt[3]) {
int[] currentVer = {majorVer, minorVer1, minorVer2};
newVerAvailable(currentVer, newestVerInt);
}
Expand Down

0 comments on commit d4efb1f

Please sign in to comment.