initial commit

This commit is contained in:
Jérémi N ‘EndMove’ 2022-08-09 18:53:52 +02:00
commit 135ce3a952
Signed by: EndMove
GPG Key ID: 65C4A02E1F5371A4
8 changed files with 149 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
build/*
!build/*.jar

1
MANIFEST.NF Normal file
View File

@ -0,0 +1 @@
Main-class: eu.endmove.hi.Main

23
README.md Normal file
View File

@ -0,0 +1,23 @@
# Hi-template
[![Donate][link-icon-coffee]][link-paypal-me] [![Website][link-icon-website]][link-website]
[link-icon-coffee]: https://img.shields.io/badge/%E2%98%95-Buy%20me%20a%20cup%20of%20coffee-991481.svg
[link-paypal-me]: https://www.paypal.me/EndMove/2.5eur
[link-icon-website]: https://img.shields.io/badge/%F0%9F%92%BB-My%20Web%20Site-0078D4.svg
[link-website]: https://www.endmove.eu/
Hi-template is a Java demo project with tools to facilitate the construction and execution of projects under windows. This project also contains a brief demonstration of how Java works, as well as the structure of a basic project.
## Use ?
Simply clone the project on your computer or download the source.
Develop your application in `src` by organizing your code and package as you wish. Then finish by editing the root file `MANIFEST.NF` and giving it the name of the main class (the one to run at startup that contains the `main` method or the entry point if you prefer).
Then use freely the `java-build-tool` to compile your project into an executable `.jar`, then run your program with the `java-run` script or via `CLI` as shown below:
```batch
java -jar built.jar
```
**😎 Thank you for choosing my template !**

BIN
build/built.jar Normal file

Binary file not shown.

23
java-build-tool.bat Normal file
View File

@ -0,0 +1,23 @@
@ECHO OFF
:: Java Build Tool powered by EndMove
ECHO === Thanks using Java Build Tool By EndMove ===
ECHO.
ECHO [+] Cleaning build directory...
RMDIR /Q /S build
MD build
ECHO Cleaning done!
ECHO [+] Converting java to bytecode...
FOR /R ./src %%f IN (*.java) DO (
javac -d build -sourcepath src %%f
)
ECHO Converting done!
ECHO [+] Building executable file...
CD build
jar -cmf ../MANIFEST.NF built.jar .
ECHO Building done!
ECHO OK. Project has been built successfuly !
TIMEOUT /T 15

15
java-run.cmd Normal file
View File

@ -0,0 +1,15 @@
@ECHO OFF
:: Java Run Tool powered by EndMove
ECHO =======================================================
ECHO Starting program...
ECHO =======================================================
ECHO.
CD build
IF exist "./built.jar" (java -jar built.jar) ELSE ECHO [ERROR] BUILT FILE NOT FOUND, PLEASE BUILD THE PROJECT.
ECHO.
ECHO =======================================================
ECHO Program finished
ECHO =======================================================
PAUSE

View File

@ -0,0 +1,38 @@
package eu.endmove.hi;
import eu.endmove.hi.model.Person; // importing Person model
/**
* Hi project
*
* To show a bit example of java basics.
*/
public class Main {
// Constants
private static final String FIRST_NAME = "Jérémi"; // jeremi firstname as a constant (can't be edited during run)
private static final String LAST_NAME = "Nihart";
// Main function
public static void main(String[] args) {
Person jeremi = new Person(FIRST_NAME, LAST_NAME); // create a jeremi person with main constructor
Person unknown = new Person(); // create a unknown person with the constructor surcharge
System.out.print("We use the toString() function on jeremi :\n==> ");
System.out.println(jeremi.toString()); // debugging jeremi person with the overrided toString() function
System.out.print("\nWe use the toString() function on unknown :\n==> ");
System.out.println(unknown.toString()); // debugging unknown person with the overrided toString() function
System.out.print("\nNow we will edit the firstName of the unknown person :\n==> ");
unknown.setFirstName("Mon nouveau nom :-)"); // updating unknown person firstname
System.out.println(unknown.toString()); // debugging unknown person with the overrided toString() function
System.out.print("\nAnd now use the getHi() function with the jeremi full name :\n==> ");
System.out.println(getHi(jeremi.getFullName())); // call getfullname() into gethi() and display
}
// Hi function
private static String getHi(String name) {
return String.format("Hi %s ! How are you today ?", name); // use a static string formatting util function available in String class
}
}

View File

@ -0,0 +1,47 @@
package eu.endmove.hi.model;
/**
* A class representing a person/human
*/
public class Person {
// Variables
private String firstName; // model object local, private variables
private String lastName;
// Constructor
public Person(String firstName, String lastName) { // complet
this.firstName = firstName;
this.lastName = lastName;
}
public Person() { // surcharge
this("No first name", "No last name");
}
// Getter
public String getFirstName() { // firstname
return this.firstName;
}
public String getLastName() { // lastname
return this.lastName;
}
public String getFullName() { // LASTNAME Firstname(first letter)
return String.format("%s %s.", this.lastName.toUpperCase(), Character.toUpperCase(this.firstName.charAt(0)));
}
// Setter
public void setFirstName(String newFirstName) { // firstname
this.firstName = newFirstName;
}
public void setLastName(String newLastName) { // lastname
this.lastName = newLastName;
}
@Override
public String toString() { // tostring overrided for debugging
return String.format("Person(firstName=\"%s\", lastName=\"%s\")", this.firstName, this.lastName);
}
}