Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
phuong161002 authored Jul 11, 2022
1 parent 8409c62 commit 373ed2b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
23 changes: 18 additions & 5 deletions BTL_OOP/src/base/BaseSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ public void InitCode() {

}

public boolean firstCheck() {
boolean isIncrease = MainWindow.frame.isIncrease;
for (int i = 0; i < elements.length - 1; i++) {
if ((isIncrease && elements[i].getValue() > elements[i + 1].getValue())
|| (!isIncrease && elements[i].getValue() < elements[i + 1].getValue())) {
return false;
}
}
return true;
}

public void Swap(int e1, int e2) {
try {
if (e1 == e2) {
Expand Down Expand Up @@ -150,12 +161,14 @@ public void MoveFollowWaypoints(Element e, Point[] waypoints, int speed) {
}

public void Sort() throws InterruptedException {
if (MainWindow.frame.isIncrease) {
SortIncrease();
} else {
SortDecrease();
}

if (!firstCheck()) {
if (MainWindow.frame.isIncrease) {
SortIncrease();
} else {
SortDecrease();
}
}
for (int i = 0; i < elements.length; i++) {
Coloring(elements[i], completedColor);
Thread.sleep(delayFrame * 10);
Expand Down
1 change: 0 additions & 1 deletion BTL_OOP/src/sorting_algorithm/RadixSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction;

public class RadixSort extends BaseSort {

Expand Down
5 changes: 3 additions & 2 deletions BTL_OOP/src/window/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ void initPanelCodeContent() {
slSize = new JSlider();
slSize.setMinimum(13);
slSize.setMaximum(20);
slSize.setValue(14);
slSize.setValue(0);
slSize.setBounds(20, 21, 466, 26); // default 10, 21, 486, 26
pnCode.add(slSize);

Expand Down Expand Up @@ -701,7 +701,8 @@ public void setZero() {
for (int i = 0; i < elements.length; i++) {
elements[i].setValue(0);
}
setState(1);
BaseSort.currentSort.UpdateSubElements();
setState(2);
this.pnImitiate.repaint();
}

Expand Down

0 comments on commit 373ed2b

Please sign in to comment.