Recursion Recursion Recursion

master
Caleb Fontenot 2023-09-17 19:41:03 +07:00
parent 44053f01f6
commit c375732331
21 changed files with 4538 additions and 0 deletions

13
.gitignore vendored

@ -156,3 +156,16 @@
/Semester 3/Assignments/MP2-chapter4_Java20_CalebFontenot/dist/
/Semester 3/Assignments/MP2-chapter4_Java20_CalebFontenot/build/
/Semester 3/Assignments/MP2_Navigation_CalebFontenot/target/
/Semester 3/Assignments/MP3_Recursion_CalebFontenot/target/
/Semester 3/Assignments/MP3_Recursion_CalebFontenot2/target/
/Semester 3/Assignments/MP3_Recusion_CalebFontenot3/nbproject/private/
/Semester 3/Assignments/MP3_Recusion_CalebFontenot3/build/
/Semester 3/Assignments/MP3_Recusion_CalebFontenot3/dist/
/Semester 3/Assignments/MP3_Recursion_CalebFontenot/nbproject/private/
/Semester 3/Assignments/MP3_Recursion_CalebFontenot/build/
/Semester 3/Assignments/SerialPog/nbproject/private/
/Semester 3/Assignments/SerialPog/build/
/Semester 3/Assignments/SerialPog/target/
/Semester 3/Assignments/SerialPog2/target/
/Semester 3/Assignments/SerialPogAnt/nbproject/private/
/Semester 3/Assignments/SerialPogAnt/build/

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="MP3_Recursion_CalebFontenot" default="default" basedir=".">
<description>Builds, tests, and runs the project MP3_Recursion_CalebFontenot.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="MP3_Recursion_CalebFontenot-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

@ -0,0 +1,8 @@
build.xml.data.CRC32=44c2f96f
build.xml.script.CRC32=0c59a678
build.xml.stylesheet.CRC32=f85dc8f2@1.107.0.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=44c2f96f
nbproject/build-impl.xml.script.CRC32=47a26e92
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.107.0.48

@ -0,0 +1,95 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.modulepath=\
${run.modulepath}
debug.test.classpath=\
${run.test.classpath}
debug.test.modulepath=\
${run.test.modulepath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/MP3_Recursion_CalebFontenot.jar
dist.javadoc.dir=${dist.dir}/javadoc
dist.jlink.dir=${dist.dir}/jlink
dist.jlink.output=${dist.jlink.dir}/MP3_Recursion_CalebFontenot
excludes=
includes=**
jar.compress=false
javac.classpath=
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.modulepath=
javac.processormodulepath=
javac.processorpath=\
${javac.classpath}
javac.source=17
javac.target=17
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.modulepath=\
${javac.modulepath}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.html5=false
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
# The jlink additional root modules to resolve
jlink.additionalmodules=
# The jlink additional command line parameters
jlink.additionalparam=
jlink.launcher=true
jlink.launcher.name=MP3_Recursion_CalebFontenot
main.class=mp3_recursion_calebfontenot.MP3_Recursion_CalebFontenot
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=JDK_17
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.modulepath=\
${javac.modulepath}
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
run.test.modulepath=\
${javac.test.modulepath}
source.encoding=UTF-8
src.dir=src
test.src.dir=test

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>MP3_Recursion_CalebFontenot</name>
<explicit-platform explicit-source-supported="true"/>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>

@ -0,0 +1,39 @@
package mp3_recursion_calebfontenot;
import java.util.Scanner;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
/**
*
* @author caleb
*/
public class BinaryToDecimal {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (true) {
System.out.print("Enter a binary number: ");
String binary = input.nextLine();
System.out.println(binary + " in decimal is " + binaryToDecimal(binary));
}
}
public static int binaryToDecimal(String binaryString) {
return binaryToDecimal(binaryString, 0, binaryString.length(), 0);
}
public static int binaryToDecimal(String binaryString, int low, int high, int value) {
if (low == binaryString.length() - 1) {
return value;
}
if (binaryString.charAt(low) == '1') {
return binaryToDecimal(binaryString, ++low, --high, value += Math.pow(2, high));
} else {
return binaryToDecimal(binaryString, ++low, --high, value);
}
}
}

@ -0,0 +1,62 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package mp3_recursion_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class DecimalToBinary {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (true) {
System.out.print("Enter a decimal integer: ");
int decimal = input.nextInt();
System.out.println(decimal + " is " + decimalToBinary(decimal) + " in binary.");
}
}
public static String decimalToBinary(int value) {
return reverse(decimalToBinary(value, ""));
}
public static String decimalToBinary(int value, String bin) {
if (value == 0) {
return bin += "";
} else if (value > 0) {
if (value % 2 == 1) {
return decimalToBinary((int) Math.floor(value / 2), bin + "1");
} else {
return decimalToBinary((int) Math.floor(value / 2), bin + "0");
}
}
return "0 naht ssel si eulav";
}
public static String reverse(String input) {
String returnString = "";
for (int i = input.length() - 1; 0 <= i; --i) {
returnString += input.charAt(i);
}
return returnString;
}
public static String decimalToBinaryIterative(int value) {
String bin = "";
while (value > 0) {
if (value % 2 == 1)
bin += "1";
else
bin += "0";
value /= 2;
}
return reverse(bin);
}
}

@ -0,0 +1,16 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
*/
package mp3_recursion_calebfontenot;
/**
*
* @author caleb
*/
public class MP3_Recursion_CalebFontenot {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}

@ -0,0 +1,325 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package mp3_recursion_calebfontenot;
import java.util.Optional;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
/**
*
* @author caleb
*/
public class Maze extends Application
{
double paneWidth = 440;
double paneHeight = 440;
private Cell[][] board = new Cell[8][8];
private Button btFindPath = new Button("Find Path Top Left to Bottom Right");
private Button btClearPath = new Button("Clear Path");
private Label lblStatus = new Label();
@Override // Override the start method in the Application class
public void start(Stage primaryStage)
{
GridPane gridPane = new GridPane();
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
gridPane.add(board[i][j] = new Cell(), j, i);
}
}
HBox hBox = new HBox(5);
hBox.setAlignment(Pos.CENTER);
hBox.getChildren().addAll(btFindPath, btClearPath);
BorderPane pane = new BorderPane();
pane.setTop(lblStatus);
BorderPane.setAlignment(lblStatus, Pos.CENTER);
pane.setCenter(gridPane);
pane.setBottom(hBox);
// Create a scene and place it in the stage
Scene scene = new Scene(pane, paneWidth, paneHeight + 60);
primaryStage.setTitle("Maze"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
btFindPath.setOnAction(e -> findPath());
btClearPath.setOnAction(e -> clearPath());
showSampleMessage();
}
public void showSampleMessage()
{
Alert a = new Alert(Alert.AlertType.CONFIRMATION);
a.setTitle("Maze Information");
a.setHeaderText(" Put this message in its proper place. ");
a.setContentText("This square cannot have an X");
Optional<ButtonType> result = a.showAndWait();
if (result.get() == ButtonType.OK)
{
System.out.println("OK ");
}
else if (result.get() == ButtonType.CANCEL)
{
System.out.println("CANCEL");
}
}
public void findPath()
{
if (findPath(0, 0))
{
lblStatus.setText("path found");
}
else
{
lblStatus.setText("No path exists");
}
}
public boolean findPath(int row, int col)
{
board[row][col].visit();
if ((col == 7) && (row == 7))
{
board[row][col].selectCell();
return true;
}
if ((row > 0) && !board[row - 1][col].marked()
&& !board[row - 1][col].blocked() && !board[row - 1][col].visited())
{
block(row, col);
if (findPath(row - 1, col))
{
board[row][col].selectCell();
return true;
}
unblock(row, col);
}
if ((row < 7) && !board[row + 1][col].marked()
&& !board[row + 1][col].blocked() && !board[row + 1][col].visited())
{
block(row, col);
if (findPath(row + 1, col))
{
board[row][col].selectCell();
return true;
}
unblock(row, col);
}
if ((col > 0) && !board[row][col - 1].marked()
&& !board[row][col - 1].blocked() && !board[row][col - 1].visited())
{
block(row, col);
if (findPath(row, col - 1))
{
board[row][col].selectCell();
return true;
}
unblock(row, col);
}
if ((col < 7) && !board[row][col + 1].marked()
&& !board[row][col + 1].blocked() && !board[row][col + 1].visited())
{
block(row, col);
if (findPath(row, col + 1))
{
board[row][col].selectCell();
return true;
}
unblock(row, col);
}
return false;
}
// Temporary block the neighbor to prevent neighboring path
public void block(int row, int col)
{
if (row > 0)
{
board[row - 1][col].block();
}
if (row < 7)
{
board[row + 1][col].block();
}
if (col > 0)
{
board[row][col - 1].block();
}
if (col < 7)
{
board[row][col + 1].block();
}
}
// Remove the temporary block
public void unblock(int row, int col)
{
if (row > 0)
{
board[row - 1][col].unblock();
}
if (row < 7)
{
board[row + 1][col].unblock();
}
if (col > 0)
{
board[row][col - 1].unblock();
}
if (col < 7)
{
board[row][col + 1].unblock();
}
}
public void clearPath()
{
for (int row = 0; row < board.length; row++)
{
for (int col = 0; col < board[row].length; col++)
{
board[row][col].deselectCell();
}
}
}
public static void main(String[] args)
{
launch(args);
}
// Inner class
class Cell extends StackPane
{
private boolean marked = false;
private boolean visited = false;
private boolean blocked = false;
double width = paneWidth / 8;
double height = paneHeight / 8;
private Rectangle rectangle = new Rectangle(0, 0, width, height);
Line line1 = new Line(0, 0, width, height);
Line line2 = new Line(width, 0, 0, height);
public Cell()
{
this.getChildren().add(rectangle);
rectangle.setFill(Color.WHITE);
rectangle.setStroke(Color.BLACK);
this.setOnMousePressed(e ->
{
marked = !marked;
if (marked)
{
mark();
}
else
{
unmark();
}
});
}
public void mark()
{
this.getChildren().addAll(line1, line2);
}
public void unmark()
{
this.getChildren().remove(line1);
this.getChildren().remove(line2);
}
public boolean marked()
{
return marked;
}
public void visit()
{
visited = true;
}
public boolean visited()
{
return visited;
}
public boolean blocked()
{
return blocked;
}
public void block()
{
blocked = true;
}
public void unblock()
{
blocked = false;
}
public void selectCell()
{
rectangle.setFill(Color.RED);
}
public void deselectCell()
{
rectangle.setFill(Color.WHITE);
blocked = false;
visited = false;
}
}
}

@ -0,0 +1,30 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package mp3_recursion_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class StringPermuatation {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a string: ");
String s = input.nextLine();
System.out.println("The permuatation for " + s + " is:");
displayPermutation(s);
}
public static void displayPermutation(String s) {
displayPermutation(" ", s);
}
public static void displayPermutation(String s1, String s2) {
if (s2.equals("")) {
}
}
}

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.calebfontenot</groupId>
<artifactId>SerialPog2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<exec.mainClass>com.calebfontenot.serialpog2.SerialPog2</exec.mainClass>
</properties>
</project>

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="SerialPogAnt" default="default" basedir=".">
<description>Builds, tests, and runs the project SerialPogAnt.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="SerialPogAnt-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

File diff suppressed because it is too large Load Diff

@ -0,0 +1,8 @@
build.xml.data.CRC32=6aa6ae3a
build.xml.script.CRC32=3b213a64
build.xml.stylesheet.CRC32=f85dc8f2@1.107.0.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=6aa6ae3a
nbproject/build-impl.xml.script.CRC32=86addcb3
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.107.0.48

@ -0,0 +1,98 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=SerialPogAnt
application.vendor=caleb
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.modulepath=\
${run.modulepath}
debug.test.classpath=\
${run.test.classpath}
debug.test.modulepath=\
${run.test.modulepath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/SerialPogAnt.jar
dist.javadoc.dir=${dist.dir}/javadoc
dist.jlink.dir=${dist.dir}/jlink
dist.jlink.output=${dist.jlink.dir}/SerialPogAnt
endorsed.classpath=
excludes=
includes=**
jar.compress=false
javac.classpath=\
${libs.RXTX.classpath}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.modulepath=
javac.processormodulepath=
javac.processorpath=\
${javac.classpath}
javac.source=17
javac.target=17
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.modulepath=\
${javac.modulepath}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.html5=false
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
# The jlink additional root modules to resolve
jlink.additionalmodules=
# The jlink additional command line parameters
jlink.additionalparam=
jlink.launcher=true
jlink.launcher.name=SerialPogAnt
main.class=serialpogant.SerialPog2
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=Graal_JDK_20
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.modulepath=\
${javac.modulepath}
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
run.test.modulepath=\
${javac.test.modulepath}
source.encoding=UTF-8
src.dir=src
test.src.dir=test

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>SerialPogAnt</name>
<explicit-platform explicit-source-supported="true"/>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>

@ -0,0 +1,48 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
*/
package serialpogant;
import java.io.OutputStream;
import java.io.IOException;
import gnu.io.*;
/**
*
* @author caleb
*/
public class SerialPog2 {
public static void main(String[] args) {
// Define the serial port name (e.g., COM3 for Windows, /dev/ttyUSB0 for Linux)
String serialPortName = "/dev/ttyACM0"; // Replace with your Arduino's serial port
// Define the baud rate (must match the Arduino sketch)
int baudRate = 9600;
try {
// Open the serial port
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(serialPortName);
SerialPort serialPort = (SerialPort) portIdentifier.open("", 2000);
// Configure the serial port
serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
// Get the output stream from the serial port
OutputStream outputStream = serialPort.getOutputStream();
// String to send to Arduino
String messageToSend = "Hello, Arduino!";
// Convert the string to bytes and write to the serial port
byte[] messageBytes = messageToSend.getBytes();
outputStream.write(messageBytes);
// Close the serial port when done
serialPort.close();
} catch (PortInUseException | NoSuchPortException | UnsupportedCommOperationException | IOException e) {
e.printStackTrace();
}
}
}