Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polishing #47

Merged
merged 2 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .idea/artifacts/myLift_jar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,16 @@ Efficiency:
to let you know your rest is done!



Instructions for .exe:
-
- Download Launch4j from https://sourceforge.net/projects/launch4j/files/latest/download
- Run the setup and launch the app
- Load the "myLift.xml" config by clicking on the folder icon
- Enjoy!


Oracle OpenJDK version 21.0.2

made by: mel n vrosh©️

Binary file modified myLift.exe
Binary file not shown.
Binary file removed myLift.jar
Binary file not shown.
24 changes: 24 additions & 0 deletions myLift.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>C:\Coding\Java\myLift\out\artifacts\myLift_jar\myLift.jar</jar>
<outfile>C:\Coding\Java\myLift\myLift.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl></downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<restartOnCrash>false</restartOnCrash>
<manifest></manifest>
<icon>C:\Coding\Java\myLift\icon.ico</icon>
<jre>
<path>%JAVA_HOME%;%PATH%</path>
<requiresJdk>false</requiresJdk>
<requires64Bit>false</requires64Bit>
<minVersion></minVersion>
<maxVersion></maxVersion>
</jre>
</launch4jConfig>
3 changes: 3 additions & 0 deletions src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: myLift

12 changes: 7 additions & 5 deletions src/data/dataManipulation.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class dataManipulation {

public dataManipulation(int index) {

// getting numberoflines of the workout
// getting the number of lines of a workout file
try {
String fileName = "src/resources/workouts/workout_" + index + ".txt";
BufferedReader br1 = new BufferedReader(new FileReader(fileName));
Expand All @@ -30,7 +30,6 @@ public dataManipulation(int index) {
e.printStackTrace();
}

// no clue why we dont need the -2 anymore but it works
this.exerciseName = new String[(noOfExercises(index))];
this.numSets = new int[(noOfExercises(index))];
this.numReps = new int[(noOfExercises(index))];
Expand All @@ -47,8 +46,8 @@ public dataManipulation() {
this.workoutNames = new String[noOfFiles()];
}

// Method to save data using ArrayList
public void saveData(workout newWorkout)
// method to save data using ArrayList
{
try {
int index = getNextIndex();
Expand All @@ -58,6 +57,7 @@ public void saveData(workout newWorkout)
bw.write(newWorkout.workoutName);
bw.newLine();

// Increment through object content and write data
for (exercise exc : newWorkout.exercises) {
bw.write(exc.exerciseName);
bw.newLine();
Expand All @@ -77,6 +77,7 @@ public void saveData(workout newWorkout)
}
}

// Parse the index file content as an integer
private int getNextIndex() {
try {
File file = new File(INDEX_FILE);
Expand All @@ -94,6 +95,7 @@ private int getNextIndex() {
}
}

// Increment index
private void updateIndex(int index) {
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(INDEX_FILE));
Expand Down Expand Up @@ -136,7 +138,7 @@ public void loadData(int index)
}
}

public int noOfFiles() { //in other words, number of workouts
public int noOfFiles() { // number of workouts
int noOfWorkouts = 0;
int i = 1;
String fileName;
Expand Down Expand Up @@ -177,7 +179,7 @@ public void loadWorkoutNames() {
workoutNames[i-1] = br.readLine();
br.close();
} catch(Exception e) {
e.printStackTrace(); // Print the stack trace for better debugging
e.printStackTrace();
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/data/exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ public exercise(String exerciseName, int numSets, int numReps, int restTime) {
this.numReps = numReps;
this.restTime = restTime;
}
}

// add getters and setters for member variables
// perform calculations or manipulations on exercise data
}
4 changes: 2 additions & 2 deletions src/data/sound.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public void setFile(int i) {
clip = AudioSystem.getClip();
clip.open(ais);
fc = (FloatControl)clip.getControl(FloatControl.Type.MASTER_GAIN);
}catch(Exception e) {
} catch(Exception e) {
}
}

public void play(){
public void play() {
clip.start();
currentVol = -10.0f;
fc.setValue(currentVol);
Expand Down
11 changes: 1 addition & 10 deletions src/data/workout.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,9 @@ public class workout {
public String workoutName;
public ArrayList<exercise> exercises; // ArrayList to store exercise objects

// Constructor
public workout(String workoutName)
{
this.workoutName = workoutName;
this.exercises = new ArrayList<exercise>();
this.exercises = new ArrayList<>();
}
}
// TODO: check if getters are necessary
//public String getWorkoutName() {
// return workoutName;
//}
//
//public void setWorkoutName(String name) {
// workoutName = name;
//}
1 change: 0 additions & 1 deletion src/myLift.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class myLift
{
public static void main (String[] args)
{

mainWindow window = new mainWindow();
}
}
4 changes: 2 additions & 2 deletions src/resources/workouts/workout_1.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Upper Day
Sample Workout
Bench Press
3
10
90
Pull Up
4
8
5
120
Incline Bench Press
3
12
Expand Down
22 changes: 3 additions & 19 deletions src/windows/addWorkoutWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.concurrent.atomic.AtomicInteger;

public class addWorkoutWindow extends JFrame {
JButton delExerciseB; // TODO: check if necessary
JButton addExerciseB, cancelWorkoutB, saveWorkoutB;
JLabel workoutNameL, exerciseNameL, noSetsL, noRepsL, noRestL;
JTextField workoutNameTF, exerciseNameTF, noSetsTF, noRepsTF, noRestTF;
Expand All @@ -23,7 +22,6 @@ public class addWorkoutWindow extends JFrame {
Color LabelC = new Color(0x73fbfd);
Color WhiteC = new Color(0xfbffff);
Color ButtonC = new Color(0x363A3D);
Color ShadowC = new Color(0x191C1D);

int bY = 200;

Expand Down Expand Up @@ -135,14 +133,6 @@ public class addWorkoutWindow extends JFrame {
saveWorkoutB.setFocusable(false);
saveWorkoutB.setBackground(ButtonC);
this.add(saveWorkoutB);

delExerciseB = new JButton("Delete Exercise");
delExerciseB.setFont(new Font("Calibri", Font.BOLD, 21));
delExerciseB.setForeground(WhiteC);
delExerciseB.setBounds(280, bY, excButtonWidth, 40);
delExerciseB.setFocusable(false);
delExerciseB.setBackground(ButtonC);
// this.add(delExerciseB);
// --------------------------------------


Expand All @@ -155,12 +145,11 @@ public class addWorkoutWindow extends JFrame {
try {
i.getAndIncrement();
addBoxRow(i.get());
this.setSize(this.getWidth(), this.getHeight() + 50);
this.setSize(this.getWidth(), this.getHeight() + 50); // Extend height
bY += 50;
addExerciseB.setBounds(160, bY, excButtonWidth, 40);
cancelWorkoutB.setBounds(20, bY, 100, 40);
saveWorkoutB.setBounds(380, bY, 100, 40);
delExerciseB.setBounds(280, bY, excButtonWidth, 40);
this.setLocationRelativeTo(null);
} catch (Exception excess) {
addExerciseB.setEnabled(false);
Expand All @@ -171,10 +160,7 @@ public class addWorkoutWindow extends JFrame {


cancelWorkoutB.addActionListener(
(e) -> {
dispose();
new mainWindow();
}
(e) -> dispose()
);


Expand Down Expand Up @@ -204,15 +190,13 @@ public class addWorkoutWindow extends JFrame {
}
}

// Call dataManipulation to save the workout (assuming dataManipulation is instantiated)
// Call dataManipulation to save the workout
dataManipulator.saveData(workoutToSave);

// Show success message
JOptionPane.showMessageDialog(null, "Workout saved successfully!", "Success", JOptionPane.INFORMATION_MESSAGE);
dispose();

} catch (Exception ex) {
// Show error message
JOptionPane.showMessageDialog(null, "You entered something wrong", "Error", JOptionPane.ERROR_MESSAGE);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/windows/infoWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class infoWindow extends JFrame
infoTextArea.setForeground(WhiteC);
infoTextArea.setBorder(BorderFactory.createLineBorder(BackgroundC, 40));

// SET LABEL TO FILE CONTENTS

// Set label to file contents
try {
BufferedReader bf = new BufferedReader(new FileReader("src/resources/info.txt"));
StringBuffer fileContent = new StringBuffer();
Expand Down
8 changes: 3 additions & 5 deletions src/windows/mainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ public class mainWindow extends JFrame
JButton addWorkoutB, viewWorkoutsB, infoB;

Color BackgroundC = new Color(0xFF2B2D30);
Color LabelC = new Color(0x73fbfd);
Color WhiteC = new Color(0xfbffff);
Color ButtonC = new Color(0x363A3D);
Color ShadowC = new Color(0x191C1D);

Image title;
ImageIcon icon = new ImageIcon("src/resources/images/icon.png");
Expand Down Expand Up @@ -60,15 +58,15 @@ public mainWindow()


addWorkoutB.addActionListener(
(e) -> {
new addWorkoutWindow();
}
(e) -> new addWorkoutWindow()
);



String[] responses = {"OK", "Create Workout"};
ImageIcon error = new ImageIcon("src/resources/images/error.png");

// Show Option Dialog if there are no workouts to list
viewWorkoutsB.addActionListener(
(e) -> {
if (dataManipulator.noOfFiles()==0) {
Expand Down
11 changes: 7 additions & 4 deletions src/windows/viewWorkoutsWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ public class viewWorkoutsWindow extends JFrame

ImageIcon icon = new ImageIcon("src/resources/images/icon.png");

dataManipulation dataManipulator = new dataManipulation();

viewWorkoutsWindow()
{

dataManipulation dataManipulator = new dataManipulation();
// --- --- WINDOW PROPERTIES --- ---
this.setLayout(null);
this.setSize(520, 600);
Expand All @@ -40,7 +41,7 @@ public class viewWorkoutsWindow extends JFrame



// --- --- --- --- BUTTONS AND ACTIONS --- --- --- ---
// --- --- --- BUTTONS AND ACTIONS --- --- ---

returnB = new JButton("←");
returnB.setFont(new Font("Calibri", Font.BOLD, 17));
Expand Down Expand Up @@ -84,6 +85,8 @@ public class viewWorkoutsWindow extends JFrame
int height = 75;
int numWorkouts = dataManipulator.noOfFiles();


// Create Labels and Buttons to view based on how many workouts there are
for (int i=0; i < numWorkouts; i++) {

String workoutName = dataManipulator.workoutNames[i];
Expand Down Expand Up @@ -113,7 +116,7 @@ public class viewWorkoutsWindow extends JFrame

infoB[i].addActionListener(
(e) -> {
new workoutInfoWindow(index); // TODO: add index for parameter
new workoutInfoWindow(index);
System.out.println(index);
}
);
Expand All @@ -136,7 +139,7 @@ public class viewWorkoutsWindow extends JFrame

height += 75;
}
// ---------------------------------------------------
// -----------------------------------------

workoutNameTitleL = new JLabel("Workout Name");
workoutNameTitleL.setBounds(175, 20, 200, 50);
Expand Down
Loading