Skip to content
Open
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
8 changes: 8 additions & 0 deletions Projek 1/H071221090_Tugas Proyek/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
"C:\\MYSQL\\mysql-connector-j-8.0.32\\mysql-connector-j-8.0.32\\mysql-connector-j-8.0.32.jar"
]
}
24 changes: 24 additions & 0 deletions Projek 1/H071221090_Tugas Proyek/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# App.java
didalam App.java terdapat method static yaitu method main. Dimana dalam method main terdapat Menu.showMenu();

# com
terdapat 1 package

## config
di dalam package config terdapat java class yaitu MyConfig
di dalamnya terdapat java class yaitu DbController terdapat method static getDatabase untuk mengambil data yang ada dalam dalam database yang kita buat, selain itu terdapat juga getProdukByNama(), insertData(), updateNama(), updateHarga(), updataStok() dan deleteData()

a. Delete: berfungsi untuk menghapus data yang ingin dihapus dengan cara menginput nama produk dengan benar

b. Edit: berfungsi untuk mengedit data yang sudah ada

c. Insert: berfungsi untuk menambahkan data baru

d. Menu: berfungsi untuk menampilkan menu serta user dapat menginput menu yang diinginkan

e. Read: berfungsi menampilkan seluruh data yang tersimpan

dan terdapat java class Produk yang menyimpan atribut Id, name, price, stock, serta terdapat method setter dan getter untuk masing-masing atribut.



Binary file added Projek 1/H071221090_Tugas Proyek/bin/App.class
Binary file not shown.
Binary file not shown.
74 changes: 74 additions & 0 deletions Projek 1/H071221090_Tugas Proyek/src/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import java.util.Scanner;

public class App {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

MyConfig.getConnection();
MyConfig.createTable();

int choice;
do {
System.out.println("------------------------");
System.out.println(" WELCOME TO ...");
System.out.println("------------------------");
System.out.println("1.] Read Data");
System.out.println("2.] Insert data");
System.out.println("3.] Edit Data");
System.out.println("4.] Delete data");
System.out.println("5.] Exit");
System.out.println("------------------------");
System.out.print("Pilih: ");

choice = input.nextInt();
input.nextLine(); // Consume the newline character

switch (choice) {
case 1:
// Read Data
MyConfig.getDatabase();
break;
case 2:
// Insert Data
System.out.print("NAMA : ");
String newNama = input.nextLine();

System.out.print("HARGA : ");
long newharga = input.nextLong();

System.out.print("STOK : ");
int newstok = input.nextInt();
MyConfig.addData(newNama, newharga, newstok);
break;
case 3:
// Edit Data
System.out.print("ID: ");
int id = input.nextInt();
input.nextLine();
System.out.print("NAMA: ");
String nama = input.nextLine();
System.out.print("HARGA: ");
int harga = input.nextInt();
System.out.print("STOK: ");
int stok = input.nextInt();
MyConfig.editData(id, nama, harga, stok);
break;
case 4:
// Delete Data
System.out.print("ID: ");
int deleteId = input.nextInt();
MyConfig.deleteData(deleteId);
break;
case 5:
System.out.println("Exiting...");
break;
default:
System.out.println("Pilihan tidak tersedia");
break;
}

} while (choice != 5);

input.close();
}
}
98 changes: 98 additions & 0 deletions Projek 1/H071221090_Tugas Proyek/src/MyConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MyConfig {

private static final String url = "jdbc:mysql://localhost:3306/imeltoko";
private static final String username = "root";
private static final String pass = "";

private static Connection connect;
private static Statement statement;

public static void getConnection() {
try {
connect = DriverManager.getConnection(url, username, pass);
System.out.println("Connected");
} catch (SQLException e) {
e.printStackTrace();

}
}

public static void getDatabase() {
try {
String query = "SELECT * FROM BARANG";
PreparedStatement statement = connect.prepareStatement(query);
ResultSet resultSet = statement.executeQuery();

while (resultSet.next()) {
int id = resultSet.getInt("ID");
String Nama = resultSet.getString("NAMA");
int Harga = resultSet.getInt("HARGA");
int Stok = resultSet.getInt("STOK");
System.out.println("ID: " + id + ", NAMA: " + Nama + ", HARGA: " + Harga + ", STOK: " + Stok);
}
} catch (SQLException e) {
e.printStackTrace();
}
}

public static void createTable() {
try {
String query = "CREATE TABLE IF NOT EXISTS BARANG (" +
"ID INT PRIMARY KEY AUTO_INCREMENT," +
"NAMA VARCHAR(255) NULL," +
"HARGA INT NULL," +
"STOK INT NULL" +
")";
PreparedStatement statement = connect.prepareStatement(query);
statement.executeUpdate();
System.out.println("Table created successfully");
} catch (SQLException e) {
e.printStackTrace();
}
}

public static void addData(String newNama, long newHarga, int newStok) {
try {
statement = connect.createStatement();
statement.executeUpdate("INSERT INTO `BARANG` (`ID`, `NAMA`, `HARGA`, `STOK`) VALUES (NULL, '"+newNama+"', '"+newHarga+"', '"+newStok+"') ");
System.out.println("Data added successfully");
} catch (Exception e) {
e.printStackTrace();
}
}

public static void editData(int ID, String NAMA, int HARGA, int STOK) {
try {
String query = "UPDATE BARANG SET NAMA=?, HARGA=?, STOK=? WHERE iD=?";
PreparedStatement statement = connect.prepareStatement(query);
statement.setString(1, NAMA);
statement.setDouble(2, HARGA);
statement.setInt(3, STOK);
statement.setInt(4, ID);
statement.executeUpdate();
System.out.println("Data updated successfully");
} catch (SQLException e) {
e.printStackTrace();
}
}

public static void deleteData(int id) {
try {
String query = "DELETE FROM BARANG WHERE ID=?";
PreparedStatement statement = connect.prepareStatement(query);
statement.setInt(1, id);
statement.executeUpdate();
System.out.println("Data deleted successfully");
} catch (SQLException e) {
e.printStackTrace();
}
}
}

73 changes: 73 additions & 0 deletions Projek 2/Kasir/build.xml
Original file line number Diff line number Diff line change
@@ -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="Kasir" default="default" basedir=".">
<description>Builds, tests, and runs the project Kasir.</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="Kasir-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>
Empty file.
Empty file.
Binary file added Projek 2/Kasir/build/classes/App/Kasirku$1.class
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/App/Kasirku$2.class
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/App/Kasirku$3.class
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/App/Kasirku$4.class
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/App/Kasirku$5.class
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/App/Kasirku.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/Kasirku/Kasirku$1.class
Binary file not shown.
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/Kasirku/Kasirku$2.class
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/Kasirku/Kasirku$3.class
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/Kasirku/Kasirku$4.class
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/Kasirku/Kasirku$5.class
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/Kasirku/Kasirku$6.class
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/Kasirku/Kasirku$7.class
Binary file not shown.
Binary file added Projek 2/Kasir/build/classes/Kasirku/Kasirku$8.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading