diff --git a/src/H071221077/Pertemuan_7/No1.java b/src/H071221077/Pertemuan_7/No1.java new file mode 100644 index 0000000..ea9a99f --- /dev/null +++ b/src/H071221077/Pertemuan_7/No1.java @@ -0,0 +1,105 @@ +abstract class Character{ + protected String name; + protected int attackPower; + + public String getName() { + return name; + } + public int getAttackPower() { + return attackPower; + } + + public Character(String name, int attackPower) { + this.name = name; + this.attackPower = attackPower; + } + + abstract int attack(); + abstract int attack(AttackType attackType); +} + +class Fighter extends Character{ + + public Fighter(String name, int attackPower) { + super(name, attackPower); + } + + @Override + int attack() { + return attackPower; + } + + @Override + int attack(AttackType attackType) { + int aP = attackPower; + if (attackType == AttackType.melee){ + aP = attackPower * 2; + }else if (attackType == AttackType.ranged){ + aP = attackPower; + } + return aP; + } +} + +class Mage extends Character{ + + public Mage(String name, int attackPower) { + super(name, attackPower); + } + + @Override + int attack() { + return attackPower; + } + + @Override + int attack(AttackType attackType) { + int serangan = attackPower; + if (attackType == AttackType.fire){ + serangan = attackPower * 3; + }else if (attackType == AttackType.frost){ + serangan = attackPower * 2; + } + return serangan; + } +} + +public class No1{ + public static void printAttack(Character character){ + System.out.println("Nama : "+ character.getName()); + System.out.println("---Attack Information---"); + System.out.println("Attack Power : "+ character.getAttackPower()); + if (character instanceof Fighter){ + System.out.println("Melee : " + character.attack(AttackType.melee)); + System.out.println("Ranged : "+ character.attack(AttackType.ranged)); + }else if (character instanceof Mage){ + System.out.println("Fire : "+ character.attack(AttackType.fire)); + System.out.println("Frost : "+ character.attack(AttackType.frost)); + } + } + public static void main(String[] args) { + Fighter fighter = new Fighter("Cheryl", 100); + Mage mage = new Mage("Dipa", 80); + Fighter fighter2 = new Fighter("Salsa", 50); + Fighter fighter3 = new Fighter("Awa", 70); + Mage mage2 = new Mage("Nakita", 60); + + Character[] hero = new Character[5]; + hero[0] = fighter; + hero[1] = mage; + hero[2] = fighter2; + hero[3] = fighter3; + hero[4] = mage2; + + for (Character i : hero){ //perulangan utk panggil objek yg ada pada hero trs mau diprint attackPowernya + printAttack(i); + System.out.println(""); + } + } +} + +enum AttackType{ + melee, frost, fire, ranged +} + + diff --git a/src/H071221077/Pertemuan_7/No2.java b/src/H071221077/Pertemuan_7/No2.java new file mode 100644 index 0000000..880dba1 --- /dev/null +++ b/src/H071221077/Pertemuan_7/No2.java @@ -0,0 +1,54 @@ +class Product

{ + protected String name; + protected P price; + protected String expDate; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public P getPrice() { + return price; + } + + public String getExpDate() { + return expDate; + } + + public Product(String name, P price, String expDate) { + this.name = name; + this.price = price; + this.expDate = expDate; + } +} + +// class Koin{ +// private int koin; + +// public int getKoin() { +// return koin; +// } + +// public Koin(int koin) { +// this.koin = koin; +// } +// } + +public class No2{ + public static void main(String[] args) { + Product product = new Product<>("Kinderjoy", 10000, "2023-05-01"); + Product product2 = new Product<>("Sari Roti", "Rp. 15.000", "2023-05-20"); + Product product3 = new Product<>("Susu Kurma", 7.5, "2023-06-01"); + //Product product4 = new Product<>("Uang", new Koin(10), "2023-06-01"); + + System.out.println("Product 1: " + product.getName() + " - " + product.getPrice() + " - " + product.getExpDate()); + System.out.println("Product 2: " + product2.getName() + " - " + product2.getPrice() + " - " + product2.getExpDate()); + System.out.println("Product 3: " + product3.getName() + " - " + product3.getPrice() + " - " + product3.getExpDate()); + //System.out.println("Product 4: " + product4.getName() + " - " + product4.getPrice().getKoin() + " - " + product4.getExpDate()); + + } +} diff --git a/src/H071221077/Pertemuan_7/No3.java b/src/H071221077/Pertemuan_7/No3.java new file mode 100644 index 0000000..befe5ee --- /dev/null +++ b/src/H071221077/Pertemuan_7/No3.java @@ -0,0 +1,75 @@ +import java.util.ArrayList; +import java.util.List; + +public class No3{ + public static void main(String[] args) { + Food burger = FoodFactory.getFood(FoodType.burger); + Food pizza = FoodFactory.getFood(FoodType.pizza); + Food steak = FoodFactory.getFood(FoodType.steak); + + List foods = new ArrayList<>(); + foods.add(burger); + foods.add(pizza); + foods.add(steak); + + int total = Restaurant.calculateTotal(foods); + System.out.println("Total price: "+ total); + } +} + +class FoodFactory{ + static Food getFood(FoodType food){ + if (food == FoodType.burger){ // tipe data "Food" krn sesuai jenisnya + return new Burger(); + }else if (food == FoodType.pizza){ + return new Pizza(); + }else if (food == FoodType.steak){ + return new Steak(); + }else{ + System.out.println("Error"); + return null; + } + } +} + +interface Food{ + public int getPrice(); +} + +class Burger implements Food{ + + @Override + public int getPrice() { + return 8000; + } +} + +class Pizza implements Food{ + + @Override + public int getPrice() { + return 10000; + } +} + +class Steak implements Food{ + + @Override + public int getPrice() { + return 15000; + } +} + +class Restaurant{ + static int calculateTotal(List foods){ + int totalPrice = 0; + for (Food food : foods){ + totalPrice += food.getPrice(); + } + return totalPrice; + } +} + +enum FoodType{ + burger, pizza, steak +} diff --git a/src/H071221077/Pertemuan_8/AppRacer.java b/src/H071221077/Pertemuan_8/AppRacer.java new file mode 100644 index 0000000..6b90c17 --- /dev/null +++ b/src/H071221077/Pertemuan_8/AppRacer.java @@ -0,0 +1,197 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; + +public class AppRacer { + public static void main(String[] args) throws InterruptedException { + Tes typeRacer = new Tes(); + typeRacer.setNewWordsToType(); + System.out.println("|| Text to Type ||"); + System.out.println("\"" + typeRacer.getWordsToType() + "\""); + + Typer[] typers = new Typer[3]; + + typers[0] = new Typer("Bot Mansur", 40, typeRacer); + typers[1] = new Typer("Bot ToKu", 32, typeRacer); + typers[2] = new Typer("Bot Yukiao", 30, typeRacer); + + typeRacer.getRaceContestant().addAll(Arrays.asList(typers)); + + typeRacer.startRace(); + } +} + +class Typer extends Thread { + private String botName, wordsTyped; + private double wpm; + private Tes typeRacer; + + public Typer(String botName, double wpm, Tes typeRacer) { + this.botName = botName; + this.wpm = wpm; + this.wordsTyped = ""; + this.typeRacer = typeRacer; + } + + public void setBotName(String botName) { + this.botName = botName; + } + + public void setWpm(int wpm) { + this.wpm = wpm; + } + + public void addWordTyped(String newWordsTyped) { + this.wordsTyped += newWordsTyped + " "; + } + + public String getWordsTyped() { + return wordsTyped; + } + + public String getBotName() { + return botName; + } + + public double getWpm() { + return wpm; + } + + @Override + public void run() { + + String[] wordsToType = typeRacer.getWordsToType().split(" "); + + // TODO (1): Buatlah variable howLongToType yang memuat waktu yang diperlukan + // typer + // untuk menulis 1 kata dalam milisecond + int howLongToType = (int) Math.floor(((60 / this.wpm)) * 1000); + + // TODO (2): Buatlah perulangan untuk menambahkan kata dengan method + // addWordToTyped setelah interval waktu sebanyak howLongToType + for (int i = 0; i < wordsToType.length; i++) { + try { + Thread.sleep(howLongToType); + addWordTyped(wordsToType[i]); + } catch (InterruptedException e) { + System.out.println("Error: " + this.botName); + } + } + + this.addWordTyped("(selesai)"); + // TODO (3): menambahkan typer yang telah selesai mengetik semua kata ke list + // typeRaceTabel yang ada di class typeRacer + typeRacer.addResult(new Result(botName, howLongToType * wordsToType.length)); + } +} + +class Result { + private String name; + private int finishTime; + + public Result(String name, int finishTime) { + this.name = name; + this.finishTime = finishTime; + } + + public String getName() { + return name; + } + + public void setName(String racerName) { + this.name = racerName; + } + + public int getFinishTime() { + return finishTime; + } + + public void setFinishTime(int racerTime) { + this.finishTime = racerTime; + } +} + +class Tes { + private String wordsToType; + private ArrayList raceContestant = new ArrayList<>(); + private ArrayList raceStanding = new ArrayList<>(); + + public String getWordsToType() { + return wordsToType; + } + + public ArrayList getRaceContestant() { + return raceContestant; + } + + // Word by Yusuf Syam, Silahkan diubah jika dirasa kurang bijak + private String[] wordsToTypeList = { + "Menuju tak terbatas dan melampauinya", + "Kehidupan adalah perjalanan yang penuh dengan lika-liku. Jadikan setiap tantangan sebagai kesempatan untuk tumbuh dan berkembang", + "Cinta sejati adalah ketika dua jiwa saling melengkapi, memberi dukungan dan menginspirasi satu sama lain untuk menjadi yang terbaik", + "Hidup adalah anugerah yang berharga. Nikmati setiap momen dan hargai kebahagiaan sederhana di sekitar kita", + "Perubahan adalah satu-satunya konstanta dalam hidup. Yang bertahan adalah mereka yang dapat beradaptasi dengan fleksibilitas", + "Kebersamaan adalah fondasi yang kuat dalam membangun hubungan yang langgeng dan bermakna", + "Masa depan adalah milik mereka yang memiliki imajinasi, tekad, dan kerja keras untuk mewujudkan visi mereka", + "Ketika kita berbagi dengan orang lain, kita tidak hanya mengurangi beban mereka, tetapi juga memperkaya hati kita sendiri", + "Kesuksesan sejati adalah ketika kita mencapai tujuan kita sambil tetap mempertahankan integritas dan empati terhadap orang lain", + "Rasa syukur adalah kunci untuk mengalami kebahagiaan yang sejati dalam hidup. Mencintai apa yang kita miliki adalah kunci kepuasan yang tak ternilai", + }; + + public void setNewWordsToType() { + Random random = new Random(); + int angkaRandom = random.nextInt(10); + wordsToType = wordsToTypeList[angkaRandom]; + } + + // TODO (4) : Buat method addResult yang mana digunakan untuk menambahkan typer + // yangtelah selesai (mengetik semua kata), ke dalam list race standing. + public synchronized void addResult(Result result) { + raceStanding.add(result); + } + + public void printRaceStanding() { + System.out.println("\nKlasemen Akhir Type Racer"); + System.out.println("=========================\n"); + + // TODO (5) : Tampilkan klasemen akhir dari kompetisi, dengan format + // {posisi}. {nama} = {waktu penyelesaian dalam detik} detik + int index = 1; + + for (Result result : raceStanding) { + System.out.printf("%d. %s - %.2f detik\n", index, result.getName(), + result.getFinishTime() / 1000.0); + index += 1; + } + } + + public void startRace() throws InterruptedException { + // TODO (6) : jalankan kompetisi + for (Typer racer : raceContestant) { + racer.start(); + } + + // TODO (7) : selaman semua peserta belum selesai, maka tampilkan + // SS + // Setiap 2 detik + while (raceContestant.size() != raceStanding.size()) { + Thread.sleep(2000); + System.out.println("\nTyping Progress ..."); + System.out.println("================\n"); + + for (Typer racer : raceContestant) { + System.out.printf("- %s\t=> %s\n", racer.getBotName(), racer.getWordsTyped()); + System.out.println("-".repeat(100)); + } + + System.out.println("\n" + "#".repeat(100)); + } + + // TODO (8) : Tampilkan race standing setelah semua typer selesai + for (Typer racer : raceContestant) { + racer.join(); + } + + printRaceStanding(); + } +} diff --git a/src/H071221077/Pertemuan_8/TugasPraktikum.java b/src/H071221077/Pertemuan_8/TugasPraktikum.java new file mode 100644 index 0000000..bcdb928 --- /dev/null +++ b/src/H071221077/Pertemuan_8/TugasPraktikum.java @@ -0,0 +1,101 @@ +package no3; + +import java.util.Random; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class TugasPraktikum { + + public static void main(String[] args) { + int numData = 4; + + UiThread uiThread = new UiThread(numData); + + ExecutorService executor = Executors.newFixedThreadPool(3); + + uiThread.start(); + + for (int i = 0; i < numData; i++) { + executor.execute(new BackgroundThread(uiThread, TaskTimeHelper.generateRandomTimeExecution())); + } + executor.shutdown(); + } +} + +class UiThread extends Thread { + private int numBackgroundThreads; + private int numThreadsSuccess = 0; + private int numThreadsFailed = 0; + private int timeExecution = 0; + + public UiThread(int numBackgroundThreads) { + this.numBackgroundThreads = numBackgroundThreads; + } + + public void run() { + System.out.println("Start load " + numBackgroundThreads + " Data"); + while ((numThreadsSuccess + numThreadsFailed) < numBackgroundThreads) { + try { + Thread.sleep(1000); + timeExecution++; + System.out.printf("Loading... (%ds)\n", timeExecution); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + System.out.println("\nTask Finish."); + System.out.println("Time Execution : " + timeExecution + "s"); + if (numThreadsFailed == 0) { + System.out.println("All data is successfully loaded"); + } else if (numThreadsSuccess == 0) { + System.out.println("All data failed to load"); + } else { + System.out.println( + numThreadsSuccess + " Data Successfully loaded & " + numThreadsFailed + " Data failed to load"); + } + } + + public synchronized void incrementNumThreadsSuccess() { + this.numThreadsSuccess++; + } + + public synchronized void incrementNumThreadsFailed() { + this.numThreadsFailed++; + } +} + +class BackgroundThread extends Thread { + private UiThread uiThread; + private int timeExecution; + + public BackgroundThread(UiThread uiThread, int timeExecution) { + this.uiThread = uiThread; + this.timeExecution = timeExecution; + } + + public void run() { + try { + for (int i = 1; i <= timeExecution; i++) { + TimeUnit.SECONDS.sleep(1); + if (i * 1000 > 2000) { + System.out.println("Request Timeout"); + uiThread.incrementNumThreadsFailed(); + return; + } + } + uiThread.incrementNumThreadsSuccess(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + +} + +class TaskTimeHelper { + static int generateRandomTimeExecution() { + Random random = new Random(); + int randomNumber = random.nextInt(6) + 1; + return randomNumber; + } +} diff --git a/src/H071221077/Pertemuan_9/.gitattributes b/src/H071221077/Pertemuan_9/.gitattributes new file mode 100644 index 0000000..097f9f9 --- /dev/null +++ b/src/H071221077/Pertemuan_9/.gitattributes @@ -0,0 +1,9 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf + +# These are Windows script files and should use crlf +*.bat text eol=crlf + diff --git a/src/H071221077/Pertemuan_9/.gitignore b/src/H071221077/Pertemuan_9/.gitignore new file mode 100644 index 0000000..1b6985c --- /dev/null +++ b/src/H071221077/Pertemuan_9/.gitignore @@ -0,0 +1,5 @@ +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build diff --git a/src/H071221077/Pertemuan_9/.vscode/settings.json b/src/H071221077/Pertemuan_9/.vscode/settings.json new file mode 100644 index 0000000..b84f89c --- /dev/null +++ b/src/H071221077/Pertemuan_9/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive", + "java.compile.nullAnalysis.mode": "automatic" +} \ No newline at end of file diff --git a/src/H071221077/Pertemuan_9/app/bin/main/image/calc.jpg b/src/H071221077/Pertemuan_9/app/bin/main/image/calc.jpg new file mode 100644 index 0000000..69c171d Binary files /dev/null and b/src/H071221077/Pertemuan_9/app/bin/main/image/calc.jpg differ diff --git a/src/H071221077/Pertemuan_9/app/build.gradle b/src/H071221077/Pertemuan_9/app/build.gradle new file mode 100644 index 0000000..5ab0188 --- /dev/null +++ b/src/H071221077/Pertemuan_9/app/build.gradle @@ -0,0 +1,38 @@ +plugins { + id 'application' + id 'org.openjfx.javafxplugin' version '0.0.13' +} + +repositories { + // Use Maven Central for resolving dependencies. + mavenCentral() +} + +dependencies { + // Use JUnit Jupiter for testing. + testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1' + + // This dependency is used by the application. + implementation 'com.google.guava:guava:31.1-jre' +} + +// Apply a specific Java toolchain to ease working on different environments. +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} +javafx { + version = "17" + modules = [ 'javafx.controls' ] +} + +application { + // Define the main class for the application. + mainClass = 'pertemuan_9.App' +} + +tasks.named('test') { + // Use JUnit Platform for unit tests. + useJUnitPlatform() +} diff --git a/src/H071221077/Pertemuan_9/app/src/main/java/pertemuan_9/App.java b/src/H071221077/Pertemuan_9/app/src/main/java/pertemuan_9/App.java new file mode 100644 index 0000000..d9699fc --- /dev/null +++ b/src/H071221077/Pertemuan_9/app/src/main/java/pertemuan_9/App.java @@ -0,0 +1,180 @@ +package pertemuan_9; + +import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.image.ImageView; +//import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import javafx.scene.text.Font; +import javafx.stage.Stage; + +public class App extends Application { + + @Override + public void start(Stage stage) { + + VBox vbox = new VBox(); + vbox.setStyle("-fx-background-color: #8FBC8F"); + //buat judul + Label judul = new Label("KALKULATOR"); + judul.setFont(Font.font("Candara", 20)); + // vbox.getChildren().add(judul); + vbox.setSpacing(12.0); + + ImageView logoCal = new ImageView("/image/calc.jpg"); + logoCal.setFitWidth(250); + logoCal.setFitHeight(230); + logoCal.setPreserveRatio(true); + logoCal.setId("logo"); + VBox.setMargin(logoCal,new Insets(10,185, 10, 185)); + + //buat tombol + Button btnStart = new Button("Mulai"); + vbox.getChildren().addAll(logoCal, judul, btnStart); + vbox.setAlignment(Pos.CENTER); + btnStart.setOnAction(action -> { + Scene1(stage); + }); + + //HBox rootNodeBox = new HBox(logoCal, vbox); + + Scene scene = new Scene(vbox, 320, 512); + stage.setScene(scene); + stage.setTitle("Kalkulator"); + stage.show(); + } + + public void Scene1(Stage stage){ + VBox vbox = new VBox(); + vbox.setStyle("-fx-background-color: #8FBC8F"); + Label judul1 = new Label("Pilih Menu"); + judul1.setFont(Font.font("Candara", 20)); + vbox.getChildren().add(judul1); + vbox.setSpacing(12.0); + + Button calc1 = new Button("Kalkulator BMI"); + vbox.getChildren().add(calc1); + vbox.setAlignment(Pos.CENTER); + vbox.setSpacing(12.0); + calc1.setOnAction(action -> { + kalkulatorBMI(stage); + }); + + Button calc2 = new Button("Kalkulator Berat Barang"); + vbox.getChildren().add(calc2); + vbox.setAlignment(Pos.CENTER); + vbox.setSpacing(12.0); + calc2.setOnAction(action -> { + beratBarang(stage); + }); + + Scene scene = new Scene(vbox, 320, 512); + stage.setScene(scene); + stage.show(); + } + + public void kalkulatorBMI(Stage stage){ + Label judul2 = new Label("KALKULATOR BMI"); + judul2.setFont(Font.font("Candara", 20)); + + TextField tfBerat = new TextField(); + tfBerat.setPromptText("Berat Badan"); + TextField tfTinggi = new TextField(); + tfTinggi.setPromptText("Tinggi Badan"); + Button btnCalculate = new Button("Hitung"); + + Label lHasil1 = new Label(); + Button btnBack = new Button("Kembali"); + btnBack.setOnAction(action -> { + Scene1(stage); + }); + btnCalculate.setOnAction(action -> { + double tinggi = Double.parseDouble(tfTinggi.getText()); + tinggi = tinggi/100; + double berat = Double.parseDouble(tfBerat.getText()); + double hasil = berat/(tinggi * tinggi); + lHasil1.setText(String.format("%f", hasil)); + + String result; + if (hasil < 18.5) { + result = "Berat badan kurang proporsional"; + } else if (hasil < 25) { + result = "Berat badan normal "; + } else if (hasil < 30) { + result = " Berat badan berlebih (berpotensi obesitas)"; + } else { + result = "Obesitas"; + } + lHasil1.setText("BMI: " + String.format("%.1f", hasil) + " - " + result); + }); + + VBox vbox = new VBox(judul2, tfBerat, tfTinggi, btnCalculate, lHasil1, btnBack); + vbox.setStyle("-fx-background-color: #8FBC8F"); + vbox.setAlignment(Pos.CENTER); + vbox.setSpacing(12.0); + + Scene scene = new Scene(vbox, 320, 512); + stage.setScene(scene); + stage.show(); + } + + public void beratBarang(Stage stage){ + Label judul3 = new Label("KALKULATOR BERAT BARANG"); + + // buat label dan field untuk berat + Label lBerat = new Label("Berat(kg): "); + TextField tfBerat = new TextField(); + tfBerat.setPromptText("Berat Barang"); + + // buat label dan field untuk jumlah barang + Label lJumlah = new Label("Jumlah: "); + TextField tfJumlahBarang = new TextField(); + tfJumlahBarang.setPromptText("Jumlah Barang"); + + // buat tombol hitung + Button btnHitung = new Button("Hitung"); + // btnHitung.setOnAction(action -> { + // hitungBeratTotal(stage); + // }); + + // buat label dan field untuk berat total + Label lBeratTotal = new Label("Berat Total(kg): "); + TextField tfBeratTotal = new TextField(); + tfBeratTotal.setPromptText("Berat Total"); + tfBeratTotal.setEditable(false); + + Label lHasil2 = new Label(); + Button btnBack2 = new Button("Kembali"); + btnBack2.setOnAction(action -> { + Scene1(stage); + }); + btnHitung.setOnAction(action -> { + try { + double berat = Double.parseDouble(tfBerat.getText()); + int jumlah = Integer.parseInt(tfJumlahBarang.getText()); + double beratTotal = berat * jumlah; + tfBeratTotal.setText(String.format("%.2f", beratTotal)); + } catch (NumberFormatException e) { + tfBeratTotal.setText("Masukan tidak valid"); + } + }); + + VBox vbox = new VBox(judul3, lBerat, tfBerat, lJumlah, tfJumlahBarang, btnHitung, lBeratTotal, tfBeratTotal, lHasil2, btnBack2); + vbox.setStyle("-fx-background-color: #8FBC8F"); + vbox.setAlignment(Pos.CENTER); + vbox.setSpacing(12.0); + + Scene scene = new Scene(vbox, 320, 512); + stage.setScene(scene); + stage.show(); + } + + public static void main(String[] args) { + launch(); + } +} \ No newline at end of file diff --git a/src/H071221077/Pertemuan_9/app/src/main/resources/image/calc.jpg b/src/H071221077/Pertemuan_9/app/src/main/resources/image/calc.jpg new file mode 100644 index 0000000..69c171d Binary files /dev/null and b/src/H071221077/Pertemuan_9/app/src/main/resources/image/calc.jpg differ diff --git a/src/H071221077/Pertemuan_9/gradle/wrapper/gradle-wrapper.properties b/src/H071221077/Pertemuan_9/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..37aef8d --- /dev/null +++ b/src/H071221077/Pertemuan_9/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/src/H071221077/Pertemuan_9/gradlew b/src/H071221077/Pertemuan_9/gradlew new file mode 100755 index 0000000..aeb74cb --- /dev/null +++ b/src/H071221077/Pertemuan_9/gradlew @@ -0,0 +1,245 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/src/H071221077/Pertemuan_9/gradlew.bat b/src/H071221077/Pertemuan_9/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/src/H071221077/Pertemuan_9/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/H071221077/Pertemuan_9/settings.gradle b/src/H071221077/Pertemuan_9/settings.gradle new file mode 100644 index 0000000..be17b70 --- /dev/null +++ b/src/H071221077/Pertemuan_9/settings.gradle @@ -0,0 +1,16 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/8.1.1/userguide/multi_project_builds.html + */ + +plugins { + // Apply the foojay-resolver plugin to allow automatic download of JDKs + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' +} + +rootProject.name = 'Pertemuan_9' +include('app')