diff --git a/src/H071211014/Pertemuan6/Assignment_main_no1.java b/src/H071211014/Pertemuan6/Assignment_main_no1.java new file mode 100644 index 0000000..dcab558 --- /dev/null +++ b/src/H071211014/Pertemuan6/Assignment_main_no1.java @@ -0,0 +1,11 @@ +public class Assignment_main_no1 { + public static void main(String[] args) { + Smartphone android = new Smartphone(1000000, "Samsung"); + android.move(); + Car ferarri = new Car(6, "blue", 250); + ferarri.move(); + Bulldog bulldog = new Bulldog(1, 100); + bulldog.move(); + bulldog.describe(); + } +} diff --git a/src/H071211014/Pertemuan6/Bulldog.java b/src/H071211014/Pertemuan6/Bulldog.java new file mode 100644 index 0000000..705a810 --- /dev/null +++ b/src/H071211014/Pertemuan6/Bulldog.java @@ -0,0 +1,17 @@ +public class Bulldog extends Dog { + + Bulldog(int position, int averageLength) { + super(position, averageLength); + } + + @Override + public void move() { + position += 1; + } + + @Override + void describe() { + System.out.println("Pendek dan berwajah besar"); + } + +} diff --git a/src/H071211014/Pertemuan6/Car.java b/src/H071211014/Pertemuan6/Car.java new file mode 100644 index 0000000..cedb928 --- /dev/null +++ b/src/H071211014/Pertemuan6/Car.java @@ -0,0 +1,16 @@ +public class Car implements Move{ + int totalFowardGear; + String color; + int maxSpeed; + + public Car(int totalFowardGear, String color, int maxSpeed) { + this.totalFowardGear = totalFowardGear; + this.color = color; + this.maxSpeed = maxSpeed; + } + + @Override + public void move() { + System.out.println("Mobil sedang berakselerasi"); + } +} diff --git a/src/H071211014/Pertemuan6/Diagram Class/DiagramClass_Pertemuan_6.png b/src/H071211014/Pertemuan6/Diagram Class/DiagramClass_Pertemuan_6.png new file mode 100644 index 0000000..32f55a7 Binary files /dev/null and b/src/H071211014/Pertemuan6/Diagram Class/DiagramClass_Pertemuan_6.png differ diff --git a/src/H071211014/Pertemuan6/Diagram Class/diagramClass.drawio b/src/H071211014/Pertemuan6/Diagram Class/diagramClass.drawio new file mode 100644 index 0000000..91bfe56 --- /dev/null +++ b/src/H071211014/Pertemuan6/Diagram Class/diagramClass.drawio @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/H071211014/Pertemuan6/Dog.java b/src/H071211014/Pertemuan6/Dog.java new file mode 100644 index 0000000..b693006 --- /dev/null +++ b/src/H071211014/Pertemuan6/Dog.java @@ -0,0 +1,11 @@ +abstract class Dog implements Move{ + int position; + int averageLength; + abstract void describe(); + + Dog(int position, int averageLength) { + this.position = position; + this.averageLength = averageLength; + } +} + diff --git a/src/H071211014/Pertemuan6/GermanShepperd.java b/src/H071211014/Pertemuan6/GermanShepperd.java new file mode 100644 index 0000000..bca5d83 --- /dev/null +++ b/src/H071211014/Pertemuan6/GermanShepperd.java @@ -0,0 +1,17 @@ +public class GermanShepperd extends Dog{ + + GermanShepperd(int position, int averageLength) { + super(position, averageLength); + } + + @Override + public void move() { + position += 3; + } + + @Override + void describe() { + System.out.println("Besar dan bertelinga lebar"); + } + +} diff --git a/src/H071211014/Pertemuan6/Move.java b/src/H071211014/Pertemuan6/Move.java new file mode 100644 index 0000000..dc3d6bf --- /dev/null +++ b/src/H071211014/Pertemuan6/Move.java @@ -0,0 +1,3 @@ +interface Move { + void move(); +} diff --git a/src/H071211014/Pertemuan6/Pitbull.java b/src/H071211014/Pertemuan6/Pitbull.java new file mode 100644 index 0000000..d6bb0f2 --- /dev/null +++ b/src/H071211014/Pertemuan6/Pitbull.java @@ -0,0 +1,17 @@ +public class Pitbull extends Dog { + + public Pitbull(int position, int averageLength) { + super(position,averageLength); + } + + @Override + public void move() { + position += 3; + } + + @Override + void describe() { + System.out.println("Berbadan besar dan kekar"); + } + +} diff --git a/src/H071211014/Pertemuan6/SiberianHusky.java b/src/H071211014/Pertemuan6/SiberianHusky.java new file mode 100644 index 0000000..46b042f --- /dev/null +++ b/src/H071211014/Pertemuan6/SiberianHusky.java @@ -0,0 +1,17 @@ +public class SiberianHusky extends Dog { + + SiberianHusky(int position, int averageLength) { + super(position, averageLength); + } + + @Override + public void move() { + position += 2; + } + + @Override + void describe() { + System.out.println("Mirip Serigala"); + } + +} diff --git a/src/H071211014/Pertemuan6/Smartphone.java b/src/H071211014/Pertemuan6/Smartphone.java new file mode 100644 index 0000000..24020f9 --- /dev/null +++ b/src/H071211014/Pertemuan6/Smartphone.java @@ -0,0 +1,14 @@ +public class Smartphone implements Move{ + int price; + String brand; + + public Smartphone(int price, String brand) { + this.price = price; + this.brand = brand; + } + + @Override + public void move() { + System.out.println("Smartphone berpindah"); + } +} diff --git a/src/H071211014/Pertemuan7/Assignment_no1.java b/src/H071211014/Pertemuan7/Assignment_no1.java new file mode 100644 index 0000000..bf0ad12 --- /dev/null +++ b/src/H071211014/Pertemuan7/Assignment_no1.java @@ -0,0 +1,25 @@ +public class Assignment_no1 { + public static void main(String[] args) { + Character[] characters = new Character[5]; + characters[0] = new Fighter(2); + characters[1] = new Mage(3); + characters[2] = new Fighter(5); + characters[3] = new Fighter(4); + characters[4] = new Mage(12); + + for(Character character : characters){ + printAttack(character); + } + } + + private static void printAttack(Character character){ + System.out.println(character.attack()); + if (character instanceof Fighter){ + System.out.println(character.attack("melee")); + System.out.println(character.attack("ranged")); + }else if (character instanceof Mage){ + System.out.println(character.attack("fire")); + System.out.println(character.attack("frost")); + } + } +} diff --git a/src/H071211014/Pertemuan7/Assignment_no2.java b/src/H071211014/Pertemuan7/Assignment_no2.java new file mode 100644 index 0000000..d7c790a --- /dev/null +++ b/src/H071211014/Pertemuan7/Assignment_no2.java @@ -0,0 +1,16 @@ +public class Assignment_no2 { + public static void main(String[] args) { + Productproduct1 = new Product("Indomie", "2024-01-01", 5000); + Productproduct2 = new Product("Ultra Milk", "2024-06-24", 6000.00); + Productproduct3 = new Product("Teh Kotak", "2024-12-31", "5000"); + + printProduct(product1); + printProduct(product2); + printProduct(product3); + + } + private static void printProduct(Product product){ + System.out.println(product.getName() + " - " + product.getExpiryDate() + " - " + product.getPrice()); + } +} + diff --git a/src/H071211014/Pertemuan7/Assignment_no3.java b/src/H071211014/Pertemuan7/Assignment_no3.java new file mode 100644 index 0000000..2f72a1d --- /dev/null +++ b/src/H071211014/Pertemuan7/Assignment_no3.java @@ -0,0 +1,20 @@ +import java.util.ArrayList; +import java.util.List; + +public class Assignment_no3 { + private static Food steak; + + public static void main(String[] args) { + Food burger = FoodFactory.getFood(FoodType.BURGER); + Food pizza = FoodFactory.getFood(FoodType.PIZZA); + List foods = new ArrayList<>(); + foods.add(burger); + foods.add(pizza); + foods.add(steak); + + int total = Restaurant.calculateTotal(foods); + + System.out.println("Total price: " + total); + + } +} diff --git a/src/H071211014/Pertemuan7/Burger.java b/src/H071211014/Pertemuan7/Burger.java new file mode 100644 index 0000000..20ff069 --- /dev/null +++ b/src/H071211014/Pertemuan7/Burger.java @@ -0,0 +1,9 @@ +public class Burger implements Food { + private final int price = 20000; + + @Override + public int getPrice() { + return price; + } + +} diff --git a/src/H071211014/Pertemuan7/Character.java b/src/H071211014/Pertemuan7/Character.java new file mode 100644 index 0000000..d5ed531 --- /dev/null +++ b/src/H071211014/Pertemuan7/Character.java @@ -0,0 +1,10 @@ +abstract class Character{ + private String name; + + public String getName() { + return name; + } + + abstract int attack(); + abstract int attack(String attackType); +} \ No newline at end of file diff --git a/src/H071211014/Pertemuan7/Fighter.java b/src/H071211014/Pertemuan7/Fighter.java new file mode 100644 index 0000000..e44d92c --- /dev/null +++ b/src/H071211014/Pertemuan7/Fighter.java @@ -0,0 +1,32 @@ +public class Fighter extends Character { + private int attackPower; + public int getAttackPower() { + return attackPower; + } + + public void setAttackPower(int attackPower) { + this.attackPower = attackPower; + } + + public Fighter(int attackPower) { + this.attackPower = attackPower; + } + + @Override + int attack() { + return attackPower; + + } + + @Override + int attack(String attackType) { + if(attackType.equalsIgnoreCase("melee")){ + return attackPower*2; + } else if(attackType.equalsIgnoreCase("ranged")){ + return attackPower; + }else{ + return -1; + } + } + +} diff --git a/src/H071211014/Pertemuan7/Food.java b/src/H071211014/Pertemuan7/Food.java new file mode 100644 index 0000000..88fdfe4 --- /dev/null +++ b/src/H071211014/Pertemuan7/Food.java @@ -0,0 +1,3 @@ +public interface Food { + int getPrice(); +} diff --git a/src/H071211014/Pertemuan7/FoodFactory.java b/src/H071211014/Pertemuan7/FoodFactory.java new file mode 100644 index 0000000..92581af --- /dev/null +++ b/src/H071211014/Pertemuan7/FoodFactory.java @@ -0,0 +1,13 @@ +public class FoodFactory { + public static Food getFood(FoodType foodType){ + if (foodType == FoodType.BURGER){ + return new Burger(); + } else if (foodType == FoodType.PIZZA){ + return new Pizza(); + } else if (foodType == FoodType.STEAK){ + return new Steak(); + }else { + return null; + } + } +} diff --git a/src/H071211014/Pertemuan7/FoodType.java b/src/H071211014/Pertemuan7/FoodType.java new file mode 100644 index 0000000..8d8ba23 --- /dev/null +++ b/src/H071211014/Pertemuan7/FoodType.java @@ -0,0 +1,3 @@ +enum FoodType { + BURGER, PIZZA, STEAK; +} diff --git a/src/H071211014/Pertemuan7/Mage.java b/src/H071211014/Pertemuan7/Mage.java new file mode 100644 index 0000000..0e49e14 --- /dev/null +++ b/src/H071211014/Pertemuan7/Mage.java @@ -0,0 +1,33 @@ +import javax.sound.sampled.AudioFileFormat.Type; + +public class Mage extends Character{ + private int attackPower; + public int getAttackPower() { + return attackPower; + } + + public void setAttackPower(int attackPower) { + this.attackPower = attackPower; + } + + public Mage(int attackPower) { + this.attackPower = attackPower; + } + + @Override + int attack() { + return attackPower; + } + + @Override + int attack(String attackType) { + if(attackType.equalsIgnoreCase("fire")){ + return attackPower*3; + } else if(attackType.equalsIgnoreCase("frost")){ + return attackPower*2; + }else{ + return -1; + } + } + +} diff --git a/src/H071211014/Pertemuan7/Pizza.java b/src/H071211014/Pertemuan7/Pizza.java new file mode 100644 index 0000000..99d590f --- /dev/null +++ b/src/H071211014/Pertemuan7/Pizza.java @@ -0,0 +1,8 @@ +public class Pizza implements Food{ + private final int price = 90000; + @Override + public int getPrice() { + return price; + } + +} diff --git a/src/H071211014/Pertemuan7/Product.java b/src/H071211014/Pertemuan7/Product.java new file mode 100644 index 0000000..518cd1d --- /dev/null +++ b/src/H071211014/Pertemuan7/Product.java @@ -0,0 +1,29 @@ +public class Product { + + private String name; + private String expiryDate; + private T price; + public Product(String name, String expiryDate, T price) { + this.name = name; + this.expiryDate = expiryDate; + this.price = price; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getExpiryDate() { + return expiryDate; + } + public void setExpiryDate(String expiryDate) { + this.expiryDate = expiryDate; + } + public T getPrice() { + return price; + } + public void setPrice(T price) { + this.price = price; + } +} diff --git a/src/H071211014/Pertemuan7/Restaurant.java b/src/H071211014/Pertemuan7/Restaurant.java new file mode 100644 index 0000000..eea0fed --- /dev/null +++ b/src/H071211014/Pertemuan7/Restaurant.java @@ -0,0 +1,11 @@ +import java.util.List; + +public class Restaurant { + public static int calculateTotal(List foods){ + int total = 0; + for (Food food : foods){ + total += food.getPrice(); + } + return total; + } +} diff --git a/src/H071211014/Pertemuan7/Steak.java b/src/H071211014/Pertemuan7/Steak.java new file mode 100644 index 0000000..ec697b8 --- /dev/null +++ b/src/H071211014/Pertemuan7/Steak.java @@ -0,0 +1,10 @@ +public class Steak implements Food { + private final int price = 120000; + @Override + public int getPrice() { + return price; + } + +} + + diff --git a/src/H071211014/Pertemuan7/desktop.ini b/src/H071211014/Pertemuan7/desktop.ini new file mode 100644 index 0000000..6f9e94c --- /dev/null +++ b/src/H071211014/Pertemuan7/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +LocalizedResourceName=@Pertemuan7,0 diff --git a/src/H071211014/Pertemuan8/No1.java b/src/H071211014/Pertemuan8/No1.java new file mode 100644 index 0000000..a6bd078 --- /dev/null +++ b/src/H071211014/Pertemuan8/No1.java @@ -0,0 +1,67 @@ +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class No1{ + private static final int dataSources = 4; + private static final int threadPools = 3; + private static int successLoadData = 0; + private static int failedLoadData = 0; + private static boolean isFinish = false; + + public static void main(String[] args) { + System.out.printf("Start Load %d data", dataSources); + ExecutorService executor = Executors.newFixedThreadPool(threadPools); + + for(int i = 0; i <= threadPools; i++){ + executor.execute(new Runnable() { + + @Override + public void run() { + int executionTime = TaskTimeHelper.getRandomNumber(); + try { + Thread.sleep(1000*executionTime); + if(executionTime > 4){ + System.out.println("Request Timeout"); + failedLoadData++; + } else{ + successLoadData++; + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + if(successLoadData + failedLoadData == dataSources){ + isFinish = true; + } + } + + }); + } + executor.shutdown(); + + int loadingTime = 1; + while (true){ + if(isFinish){ + System.out.println("Task Finish"); + System.out.println("Time Execution "+ (loadingTime-1)); + if(successLoadData == dataSources){ + System.out.println("All data succesfully loaded"); + break; + } else{ + System.out.println("Data Failed to load" + failedLoadData); + break; + } + + } else{ + System.out.println("Loading..."+ "(" + loadingTime+"s" +")"); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + loadingTime++; + } + + } + + } +} \ No newline at end of file diff --git a/src/H071211014/Pertemuan8/No2.java b/src/H071211014/Pertemuan8/No2.java new file mode 100644 index 0000000..44202aa --- /dev/null +++ b/src/H071211014/Pertemuan8/No2.java @@ -0,0 +1,23 @@ +import java.util.Arrays; + +public class No2 { + + public static void main(String[] args) throws InterruptedException { + TypeRacer typeRacer = new TypeRacer(null, null, null); + typeRacer.setNewWordsToType(); + System.out.println("|| Text to Type ||"); + System.out.println("\"" + typeRacer.getWordsToType() + "\""); + + Typer[] typers = new Typer[3]; + + typers[0] = new Typer("Bot Mansur", 80, typeRacer); + typers[1] = new Typer("Bot Toku", 72, typeRacer); + typers [2] = new Typer("Bot Yukiao", 70, typeRacer); + + typeRacer.getRaceContestant().addAll(Arrays.asList(typers)); + + typeRacer.startRace(); + + } + +} diff --git a/src/H071211014/Pertemuan8/Result.java b/src/H071211014/Pertemuan8/Result.java new file mode 100644 index 0000000..9a66e81 --- /dev/null +++ b/src/H071211014/Pertemuan8/Result.java @@ -0,0 +1,21 @@ +public 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 name) { + this.name = name; + } + public int getFinishTime() { + return finishTime; + } + public void setFinishTime(int finishTime) { + this.finishTime = finishTime; + } + +} diff --git a/src/H071211014/Pertemuan8/TaskTimeHelper.java b/src/H071211014/Pertemuan8/TaskTimeHelper.java new file mode 100644 index 0000000..8c5c7cc --- /dev/null +++ b/src/H071211014/Pertemuan8/TaskTimeHelper.java @@ -0,0 +1,8 @@ +import java.util.Random; + +public class TaskTimeHelper { + public static int getRandomNumber(){ + Random random = new Random(); + return random.nextInt(6)+1; + } +} diff --git a/src/H071211014/Pertemuan8/TypeRacer.java b/src/H071211014/Pertemuan8/TypeRacer.java new file mode 100644 index 0000000..b9a057e --- /dev/null +++ b/src/H071211014/Pertemuan8/TypeRacer.java @@ -0,0 +1,39 @@ +import java.util.ArrayList; + +public class TypeRacer { + private String wordsToType; + private ArrayList raceContestant = new ArrayList<>(); + private ArrayList raceStanding = new ArrayList<>(); + + public TypeRacer(String wordsToType, ArrayList raceContestant, ArrayList raceStanding) { + this.wordsToType = wordsToType; + this.raceContestant = raceContestant; + this.raceStanding = raceStanding; + + + } + public String getWordsToType() { + return wordsToType; + } + public void setWordsToType(String wordsToType) { + this.wordsToType = wordsToType; + } + public ArrayList getRaceContestant() { + return raceContestant; + } + public void setRaceContestant(ArrayList raceContestant) { + this.raceContestant = raceContestant; + } + public ArrayList getRaceStanding() { + return raceStanding; + } + public void setRaceStanding(ArrayList raceStanding) { + this.raceStanding = raceStanding; + } + public void addResult(Typer typer) { + } + public void startRace() { + } + public void setNewWordsToType() { + } +} diff --git a/src/H071211014/Pertemuan8/Typer.java b/src/H071211014/Pertemuan8/Typer.java new file mode 100644 index 0000000..c6a00e7 --- /dev/null +++ b/src/H071211014/Pertemuan8/Typer.java @@ -0,0 +1,61 @@ +public class Typer extends Thread { + private String botName, wordsTyped; + private double wpm; // Words Per Minute + private TypeRacer typeRacer; + + public Typer(String botName, double wpm, TypeRacer typeRacer) { + this.botName = botName; + this.wpm = wpm; + this.wordsTyped = ""; + this.typeRacer = typeRacer; + } + + public void setBotName(String botName) { + this.botName = botName; + } + + public void setWpm(double 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 + // divided 6000 from milisecond + int howLongToType = (int) (60000 / wpm); + + // TODO 2 + for (String word : wordsToType) { + try { + Thread.sleep(howLongToType); + this.addWordTyped(word); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + this.addWordTyped("(selesai)"); + + // TODO 3 + typeRacer.addResult(this); + } +} \ No newline at end of file diff --git a/src/H071211014/Pertemuan8/WordsTyped.java b/src/H071211014/Pertemuan8/WordsTyped.java new file mode 100644 index 0000000..d649463 --- /dev/null +++ b/src/H071211014/Pertemuan8/WordsTyped.java @@ -0,0 +1,83 @@ +import java.util.ArrayList; +import java.util.Random; + +public class WordsTyped { + private String wordsToType; + private ArrayList raceContestant = new ArrayList<>(); + private ArrayList raceStanding = new ArrayList<>(); + + public String getWordsToType() { + return wordsToType; + } + + public ArrayList getRaceContestant() { + return raceContestant; + } + + private String[] wordsToTypeList = { "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 randomNumber = random.nextInt(wordsToTypeList.length); + wordsToType = wordsToTypeList[randomNumber]; + } + + // TODO 4 + public void addResult(Typer typer) { + int timeResult = typer.getWordsTyped().split(" ").length * (int) (60000 / typer.getWpm()); + Result result = new Result(typer.getBotName(), timeResult); + raceStanding.add(result); + } + + public void printRaceStanding() { + System.out.println("\nKlasemen Akhir Type Racer"); + System.out.println("=========================\n"); + + // TODO 5 + for (int i = 0; i < raceStanding.size(); i++) { + int finishTime = raceStanding.get(i).getFinishTime(); + double finishTimeInSeconds = (double) finishTime / 1000; + System.out.println(String.format("%d. %s = %.2f detik", i+1, raceStanding.get(i).getName(), finishTimeInSeconds)); + } + + } + + public void startRace() { + // TODO 6 + setNewWordsToType(); + System.out.println(); + + for (Typer typer : raceContestant) { + typer.start(); + } + + // TODO 7 + boolean isAllFinished = false; + while (true) { + if (!isAllFinished) { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + System.out.println("\n#################################################################################################"); + System.out.println("\nTyping Progress ..."); + System.out.println("================\n"); + for (Typer typer : raceContestant) { + System.out.println(String.format("- %s => %s", typer.getBotName(), typer.getWordsTyped())); + System.out.println("===================================================================================================="); + } + + if (raceContestant.size() == raceStanding.size()) { + isAllFinished = true; + } + } else { + break; + } + } + + // TODO 8 + printRaceStanding(); + } +} \ No newline at end of file diff --git a/src/H071211014/Pertemuan_2/Alamat.java b/src/H071211014/Pertemuan_2/Alamat.java new file mode 100644 index 0000000..2d7c08b --- /dev/null +++ b/src/H071211014/Pertemuan_2/Alamat.java @@ -0,0 +1,9 @@ +package H071211014.Pertemuan_2; +public class Alamat { + String jalan; + String kota; + + String getAlamatLengkap(){ + return jalan+", "+kota; + } +} diff --git a/src/H071211014/Pertemuan_2/Assignment_2_1.java b/src/H071211014/Pertemuan_2/Assignment_2_1.java new file mode 100644 index 0000000..a8b224c --- /dev/null +++ b/src/H071211014/Pertemuan_2/Assignment_2_1.java @@ -0,0 +1,13 @@ +package H071211014.Pertemuan_2; + +public class Assignment_2_1 { + public static void main(String[] args) { + StadiumBola stadium = new StadiumBola(); + stadium.namaStadium = "Camp Nou"; + stadium.jumlahKursi = 99_354; + stadium.luasLapangan = 7140; + stadium.lokasi = "Barcelona"; + + stadium.deskripsi(); + } +} \ No newline at end of file diff --git a/src/H071211014/Pertemuan_2/Assignment_2_2.java b/src/H071211014/Pertemuan_2/Assignment_2_2.java new file mode 100644 index 0000000..91af0de --- /dev/null +++ b/src/H071211014/Pertemuan_2/Assignment_2_2.java @@ -0,0 +1,13 @@ +package H071211014.Pertemuan_2; +public class Assignment_2_2 { + public static void main(String[] args) { + Person person = new Person(); + person.setName("Attar"); + person.setAge(19); + person.setGender(true); + + System.out.println("Nama: "+ person.getName()); + System.out.println("Umur: "+ person.getAge()); + System.out.println("Gender: "+ person.getGender()); + } +} diff --git a/src/H071211014/Pertemuan_2/Assignment_2_3.java b/src/H071211014/Pertemuan_2/Assignment_2_3.java new file mode 100644 index 0000000..b5bb7d5 --- /dev/null +++ b/src/H071211014/Pertemuan_2/Assignment_2_3.java @@ -0,0 +1,21 @@ +package H071211014.Pertemuan_2; + +public class Assignment_2_3 { + public static void main(String[] args) { + Product product1 = new Product(); + product1.id = "H01"; + product1.nama ="Jersey"; + product1.stok = 7070; + product1.harga = 70000; + + product1.productDescription(); + + Product product2 = new Product(); + product2.id = "H03"; + product2.nama ="Sepatu"; + product2.stok = 0; + product2.harga = 200000; + + product2.productDescription(); + } +} diff --git a/src/H071211014/Pertemuan_2/Assignment_2_4.java b/src/H071211014/Pertemuan_2/Assignment_2_4.java new file mode 100644 index 0000000..e7a2045 --- /dev/null +++ b/src/H071211014/Pertemuan_2/Assignment_2_4.java @@ -0,0 +1,13 @@ +package H071211014.Pertemuan_2; +public class Assignment_2_4 { + public static void main(String[] args) { + Cuboid cuboid = new Cuboid(); + cuboid.height = 25; + cuboid.width = 20; + cuboid.length = 9; + + System.out.printf("Volume = %.2f", cuboid.getVolume()); + + } + +} diff --git a/src/H071211014/Pertemuan_2/Assignment_2_5.java b/src/H071211014/Pertemuan_2/Assignment_2_5.java new file mode 100644 index 0000000..c62f127 --- /dev/null +++ b/src/H071211014/Pertemuan_2/Assignment_2_5.java @@ -0,0 +1,17 @@ +package H071211014.Pertemuan_2; +public class Assignment_2_5 { + public static void main(String[] args) { + Alamat alamat = new Alamat(); + alamat.jalan = "Tamalanrea Jaya"; + alamat.kota = "Makassar"; + + Mahasiswa mahasiswa = new Mahasiswa(); + mahasiswa.alamat = alamat; + mahasiswa.nama = "Attar"; + mahasiswa.nim = "H071211014"; + + System.out.println("Nama: " + mahasiswa.getNama()); + System.out.println("NIM: " + mahasiswa.getNim()); + System.out.println("Alamat: " + mahasiswa.getAlamat().getAlamatLengkap()); + } +} diff --git a/src/H071211014/Pertemuan_2/Cuboid.java b/src/H071211014/Pertemuan_2/Cuboid.java new file mode 100644 index 0000000..b858659 --- /dev/null +++ b/src/H071211014/Pertemuan_2/Cuboid.java @@ -0,0 +1,12 @@ +package H071211014.Pertemuan_2; + +public class Cuboid { + double height; + double width; + double length; + + double getVolume() { + return height*width*length; + } + +} diff --git a/src/H071211014/Pertemuan_2/Mahasiswa.java b/src/H071211014/Pertemuan_2/Mahasiswa.java new file mode 100644 index 0000000..92bea72 --- /dev/null +++ b/src/H071211014/Pertemuan_2/Mahasiswa.java @@ -0,0 +1,19 @@ +package H071211014.Pertemuan_2; + +public class Mahasiswa { + Alamat alamat; + String nama; + String nim; + + String getNama(){ + return nama; + } + + String getNim(){ + return nim; + } + + Alamat getAlamat(){ + return alamat; + } +} diff --git a/src/H071211014/Pertemuan_2/Person.java b/src/H071211014/Pertemuan_2/Person.java new file mode 100644 index 0000000..f9c396c --- /dev/null +++ b/src/H071211014/Pertemuan_2/Person.java @@ -0,0 +1,34 @@ +package H071211014.Pertemuan_2; +public class Person { + public String name; + public int age; + public boolean isMale; + + public void setName(String name){ + this.name = name; + } + + public String getName(){ + return name; + } + + public void setAge(int age){ + this.age = age; + } + + public int getAge(){ + return age; + } + + public void setGender(Boolean isMale){ + this.isMale = isMale; + } + + public String getGender(){ + if(isMale){ + return "male"; + } else{ + return "female"; + } + } +} diff --git a/src/H071211014/Pertemuan_2/Product.java b/src/H071211014/Pertemuan_2/Product.java new file mode 100644 index 0000000..a2d970c --- /dev/null +++ b/src/H071211014/Pertemuan_2/Product.java @@ -0,0 +1,23 @@ +package H071211014.Pertemuan_2; +public class Product { + String id; + String nama; + int stok; + int harga; + + Boolean isProductAvailable(){ + if(stok>0){ + return true; + } else{ + return false; + } + + } + + void productDescription(){ + System.out.println("Id produk: "+ id); + System.out.println("Nama produk: "+ nama); + System.out.println("Harga: Rp."+ harga); + System.out.println("Ketersediaan: "+isProductAvailable()); + } +} diff --git a/src/H071211014/Pertemuan_2/StadiumBola.java b/src/H071211014/Pertemuan_2/StadiumBola.java new file mode 100644 index 0000000..85277db --- /dev/null +++ b/src/H071211014/Pertemuan_2/StadiumBola.java @@ -0,0 +1,16 @@ +package H071211014.Pertemuan_2; + + +public class StadiumBola { + String namaStadium; + int jumlahKursi; + int luasLapangan; + String lokasi; + + void deskripsi(){ + System.out.println(namaStadium); + System.out.println("berlokasi di "+ lokasi); + System.out.println("dengan jumlah kursi "+ jumlahKursi); + System.out.println("dan memiliki luas lapangan sebesar "+ luasLapangan + "m"); + } +} diff --git a/src/H071211014/Pertemuan_3/Assignment_3_1.java b/src/H071211014/Pertemuan_3/Assignment_3_1.java new file mode 100644 index 0000000..595f036 --- /dev/null +++ b/src/H071211014/Pertemuan_3/Assignment_3_1.java @@ -0,0 +1,10 @@ +package H071211014.Pertemuan_3; + +public class Assignment_3_1 { + public static void main(String[] args) { + KlubBola barcelona = new KlubBola("barcelona", "barcelona", new Stadium("Camp Nou", "Barcelona", 99000, 1234)); + KlubBola chelsea = new KlubBola("chelsea", "london", new Stadium("Stamford Bridge", "London", 48000, 1212)); + barcelona.tanding(chelsea); + barcelona.juara("UCL"); + } +} diff --git a/src/H071211014/Pertemuan_3/Assignment_3_2.java b/src/H071211014/Pertemuan_3/Assignment_3_2.java new file mode 100644 index 0000000..89752d1 --- /dev/null +++ b/src/H071211014/Pertemuan_3/Assignment_3_2.java @@ -0,0 +1,15 @@ +package H071211014.Pertemuan_3; +public class Assignment_3_2 { + public static void main(String[] args) { + + Player player1 = new Player("Mino", 30, 15); + Player player2 = new Player("Hilda", 10); + + player2.setAttackPower(35); + + player1.getDamage(player2); + + player1.status(); + player2.status(); + } +} diff --git a/src/H071211014/Pertemuan_3/Assignment_3_3.java b/src/H071211014/Pertemuan_3/Assignment_3_3.java new file mode 100644 index 0000000..7b45d1f --- /dev/null +++ b/src/H071211014/Pertemuan_3/Assignment_3_3.java @@ -0,0 +1,51 @@ +package H071211014.Pertemuan_3; +import java.util.Scanner; + +public class Assignment_3_3 { + public static void main(String[] args) { + User user = new User("Attar", 1000000); + Store store = new Store("Sisfo Store"); + Product product1 = new Product("Baju kemeja", 100000, 20); + Product product2 = new Product("Celana jeans", "80k", 15); + Product product3 = new Product("Sepatu", "200k", 15); + Product product4 = new Product("Baju kaos", "50k", 30); + Product product5 = new Product("Topi", "70k", 20); + Product product6 = new Product("Jaket", "100k", 1); + Product product7 = new Product("Jersey Barca","1500k" , 11); + + store.addProduct(product1); + store.addProduct(product2); + store.addProduct(product3); + store.addProduct(product4); + store.addProduct(product5); + store.addProduct(product6); + store.addProduct(product7); + + Scanner scanner = new Scanner(System.in); + while (true){ + user.showCard(); + store.showProducts(); + System.out.print("Pilihan Opsi: "); + int selectedProductIndex = scanner.nextInt(); + if (selectedProductIndex == 0){ + break; + } + + store.showConfirmation(selectedProductIndex-1); + int confirmationIndex = scanner.nextInt(); + if (confirmationIndex == 1){ + store.transaction(user, selectedProductIndex-1); + store.showFinishedTransaction(); + int continueTransactionIndex = scanner.nextInt(); + if (continueTransactionIndex == 2){ + break; + } + } else if (confirmationIndex == 2){ + continue; + } + System.out.println(); + } + scanner.close(); + } +} + diff --git a/src/H071211014/Pertemuan_3/KlubBola.java b/src/H071211014/Pertemuan_3/KlubBola.java new file mode 100644 index 0000000..f72a6f3 --- /dev/null +++ b/src/H071211014/Pertemuan_3/KlubBola.java @@ -0,0 +1,26 @@ +package H071211014.Pertemuan_3; +public class KlubBola { + String nama; + String kota; + Stadium stadium; + + public KlubBola(String nama, String kota, Stadium stadium){ + this.nama = nama; + this.kota = kota; + this.stadium = stadium; + } + + public KlubBola(String nama, String kota){ + this.nama = nama; + this.kota = kota; + this.stadium = new Stadium("Miskin ndk punya stadium", "tidak berlokasi", 0, 0); + } + + public void tanding(KlubBola lawan){ + System.out.printf("%s vs %s\n", this.nama, lawan.nama); + } + + public void juara(String kompetisi){ + System.out.println(this.nama + " menjuarai kompetisi " + kompetisi); + } +} diff --git a/src/H071211014/Pertemuan_3/Player.java b/src/H071211014/Pertemuan_3/Player.java new file mode 100644 index 0000000..9e4aa32 --- /dev/null +++ b/src/H071211014/Pertemuan_3/Player.java @@ -0,0 +1,40 @@ +package H071211014.Pertemuan_3; +public class Player { + private String name; + private int hp = 100; + private int attackPower; + private int defense; + + + public Player(String name, int attackPower, int defense){ + this.name = name; + this.attackPower = attackPower; + this.defense = defense; + } + + public Player(String name, int defense){ + this.name = name; + this.defense = defense; + } + + public void getDamage(Player enemy){ + hp= hp-Math.abs(enemy.getAttackPower()-defense); + } + + public void setAttackPower(int attackPower){ + this.attackPower = attackPower; + } + + + + public void status() { + System.out.println(name + " status"); + System.out.println("HP = " + hp); + System.out.println("Defense = "+ defense); + System.out.println("Attack = "+ attackPower + "\n"); + } + + int getAttackPower() { + return attackPower; + } +} diff --git a/src/H071211014/Pertemuan_3/Product.java b/src/H071211014/Pertemuan_3/Product.java new file mode 100644 index 0000000..93a28c2 --- /dev/null +++ b/src/H071211014/Pertemuan_3/Product.java @@ -0,0 +1,35 @@ +package H071211014.Pertemuan_3; +public class Product { + String name; + int price; + int stock; + + public Product(String name, int price, int stock){ + this.name = name; + this.price = price; + this.stock = stock; + } + + public Product(String name, String price, int stock){ + this.name = name; + this.price = Integer.parseInt(price.substring(0, price.length()-1)+ "000"); + this.stock = stock; + } + + public String getName(){ + return name; + } + + public int getPrice(){ + return price; + } + + public int getStock(){ + return stock; + } + + public void sold(){ + stock = stock-1; + } + +} diff --git a/src/H071211014/Pertemuan_3/Stadium.java b/src/H071211014/Pertemuan_3/Stadium.java new file mode 100644 index 0000000..3f2b054 --- /dev/null +++ b/src/H071211014/Pertemuan_3/Stadium.java @@ -0,0 +1,14 @@ +package H071211014.Pertemuan_3; +public class Stadium { + String nama; + String lokasi; + int jumlahBangku; + int luasLapangan; + + public Stadium(String nama,String lokasi, int jumlahBangku, int luasLapangan){ + this.nama = nama; + this.lokasi = lokasi; + this.jumlahBangku = jumlahBangku; + this.luasLapangan = luasLapangan; + } +} diff --git a/src/H071211014/Pertemuan_3/Store.java b/src/H071211014/Pertemuan_3/Store.java new file mode 100644 index 0000000..1af1f41 --- /dev/null +++ b/src/H071211014/Pertemuan_3/Store.java @@ -0,0 +1,58 @@ +package H071211014.Pertemuan_3; +import java.util.ArrayList; + +public class Store { + String name; + ArrayList products; + + public Store(String name){ + this.name = name; + products = new ArrayList<>(); + } + + public void addProduct(Product product){ + products.add(product); + } + + public void showProducts(){ + System.out.println("Selamat Datang di "+ name); + System.out.println("Daftar Produk:"); + int index = 1; + for (Product product : products) { + System.out.printf("%d. %s - Rp%d | Stock %d\n", index, product.name, product.price, product.stock); + index++; + } + System.out.println("0. Keluar"); + + } + + public void transaction(User user, int index){ + Product product = products.get(index); + if (user.getBalance() >= product.getPrice()){ + user.balance = user.getBalance() - product.getPrice(); + product.stock = product.stock - 1; + if (product.stock <= 0){ + products.remove(product); + } + System.out.println(user.getName()+ " berhasil membeli " + product.getName()); + } else{ + System.out.println("Maaf uang anda tidak cukup untuk membeli barang ini"); + } + } + + public void showConfirmation(int index){ + Product product = products.get(index); + System.out.println("Apakah anda yakin ingin membeli: "); + System.out.println(product.getName()+ ", dengan harga Rp"+ product.getPrice()); + System.out.println("1. Konfirmasi"); + System.out.println("2. Batal"); + } + + public void showFinishedTransaction(){ + System.out.println("--------------------"); + System.out.println("Lanjutkan transaksi?"); + System.out.println("1. Ya"); + System.out.println("2. Tidak"); + } +} + diff --git a/src/H071211014/Pertemuan_3/User.java b/src/H071211014/Pertemuan_3/User.java new file mode 100644 index 0000000..c5a78fe --- /dev/null +++ b/src/H071211014/Pertemuan_3/User.java @@ -0,0 +1,26 @@ +package H071211014.Pertemuan_3; +public class User { + String name; + int balance; + + public User(String name, int balance){ + this.name = name; + this.balance = balance; + } + + public String getName(){ + return name; + } + + public int getBalance(){ + return balance; + } + + public void showCard(){ + System.out.println("---------Card----------"); + System.out.println(name); + System.out.println("Rp"+balance); + System.out.println("-----------------------"); + } + +} diff --git a/src/H071211014/Pertemuan_3/playe b/src/H071211014/Pertemuan_3/playe new file mode 100644 index 0000000..e69de29 diff --git a/src/H071211014/Pertemuan_4/Tugas4/Film.java b/src/H071211014/Pertemuan_4/Tugas4/Film.java new file mode 100644 index 0000000..47ebd91 --- /dev/null +++ b/src/H071211014/Pertemuan_4/Tugas4/Film.java @@ -0,0 +1,73 @@ +package H071211014.Pertemuan_4.Tugas4; + +public class Film { + private String title; + private int duration; + private String director; + private String genre; + private String synopsis; + + + public String getTitle() { + return title; + } + + public int getDuration() { + return duration; + } + + public String getDirector() { + return director; + } + + public String getGenre() { + return genre; + } + + public String getSynopsis() { + return synopsis; + } + + Film(){ + + } + + Film(String title, int duration, String director, String genre, String synopsis){ + this.title = title; + this.duration = duration; + this.director = director; + this.genre = genre; + this.synopsis = synopsis; + } + + public void displayInfo(){ + System.out.println("Judul: "+ title); + System.out.println("Durasi: "+ duration + " menit"); + System.out.println("Sutradara: "+ director); + System.out.println("Genre: "+ genre); + System.out.println("Sinopsis: "+ synopsis); + } + + public void setTitle(String title) { + this.title = title; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public void setDirector(String director) { + this.director = director; + } + + public void setGenre(String genre) { + this.genre = genre; + } + + public void setSynopsis(String synopsis) { + this.synopsis = synopsis; + } + + + +} diff --git a/src/H071211014/Pertemuan_4/Tugas4/Main.java b/src/H071211014/Pertemuan_4/Tugas4/Main.java new file mode 100644 index 0000000..82a3388 --- /dev/null +++ b/src/H071211014/Pertemuan_4/Tugas4/Main.java @@ -0,0 +1,32 @@ +package H071211014.Pertemuan_4.Tugas4; + + +public class Main { + public static void main(String[] args) { + Film film = new Film(); + film.setTitle("Spiderman No Way Home"); + film.setDuration(120); + film.setDirector("Jon Watts"); + film.setGenre("Action"); + film.setSynopsis("With Spider-Man's identity now revealed, our friendly neighborhood web-slinger is unmasked and no longer able to separate his normal life as Peter Parker from the high stakes of being a superhero. When Peter asks for help from Doctor Strange, the stakes become even more dangerous, forcing him to discover what it truly means to be Spider-Man."); + film.displayInfo(); + System.out.println(); + + Film film2 = new Film( + "Black Panther", + 120, + "Ryan Coogler", + "Action", + "Plot. Thousands of years ago, five African tribes war over a meteorite containing the metal vibranium. One warrior ingests a \"heart-shaped herb\" affected by the metal and gains superhuman abilities, becoming the first \"Black Panther\". He unites all but the Jabari Tribe to form the nation of Wakanda." + ); + System.out.println("Judul: "+ film2.getTitle()); + System.out.println("Durasi: "+ film2.getDuration()+ " menit"); + System.out.println("Sutradara: "+ film2.getDirector()); + System.out.println("Genre: "+ film2.getGenre()); + System.out.println("Sinopsis: "+ film2.getSynopsis()); + + System.out.println(); + SelfUtils.displaySelfData(); + + } +} diff --git a/src/H071211014/Pertemuan_4/Tugas4/SelfUtils.java b/src/H071211014/Pertemuan_4/Tugas4/SelfUtils.java new file mode 100644 index 0000000..8ffba11 --- /dev/null +++ b/src/H071211014/Pertemuan_4/Tugas4/SelfUtils.java @@ -0,0 +1,9 @@ +package H071211014.Pertemuan_4.Tugas4; + +public class SelfUtils { + public static void displaySelfData(){ + System.out.println("Nama: Attar Musharih"); + System.out.println("NIM: H071211014"); + } + +} diff --git a/src/H071211014/Pertemuan_5/Anggota.java b/src/H071211014/Pertemuan_5/Anggota.java new file mode 100644 index 0000000..06a3bcc --- /dev/null +++ b/src/H071211014/Pertemuan_5/Anggota.java @@ -0,0 +1,14 @@ +public class Anggota { + String nama; + String jabatan; + + public Anggota(String nama, String jabatan) { + this.nama = nama; + this.jabatan = jabatan; + } + + public void tampilkanInfo() { + System.out.println("Nama: " + nama); + System.out.println("Jabatan: " + jabatan); + } + } diff --git a/src/H071211014/Pertemuan_5/Assignment_5_1.java b/src/H071211014/Pertemuan_5/Assignment_5_1.java new file mode 100644 index 0000000..6c37bf9 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Assignment_5_1.java @@ -0,0 +1,41 @@ +package H071211014.Pertemuan_5; + +public class Assignment_5_1 { + public static void main(String[] args) { + Kubus kubus = new Kubus(5.0); + System.out.println("Volume kubus: " + kubus.hitungVolume()); + + Bola bola = new Bola(7.0); + System.out.println("Volume bola: " + bola.hitungVolume()); + + Balok balok = new Balok(4.0, 6.0, 8.0); + System.out.println("Volume balok: " + balok.hitungVolume()); + + Tabung tabung = new Tabung(3.0, 10.0); + System.out.println("Volume tabung: " + tabung.hitungVolume()); + + Persegi persegi = new Persegi(5.0); + System.out.println("Luas persegi: " + persegi.hitungLuas()); + System.out.println("Keliling persegi: " + persegi.hitungKeliling()); + + PersegiPanjang persegiPanjang = new PersegiPanjang(4.0, 6.0); + System.out.println("Luas persegi panjang: " + persegiPanjang.hitungLuas()); + System.out.println("Keliling persegi panjang: " + persegiPanjang.hitungKeliling()); + + Lingkaran lingkaran = new Lingkaran(3.0); + System.out.println("Luas lingkaran: " + lingkaran.hitungLuas()); + System.out.println("Keliling lingkaran: " + lingkaran.hitungKeliling()); + + Segitiga segitiga1 = new Segitiga(5.0, 7.0); + System.out.println("Luas segitiga (alas=5, tinggi=7): " + segitiga1.hitungLuas()); + + Segitiga segitiga2 = new Segitiga(3.0, 4.0, 5.0); + System.out.println("Keliling segitiga (sisi1=3, sisi2=4, sisi3=5): " + segitiga2.hitungKeliling()); + + Trapesium trapesium1 = new Trapesium(3.0, 5.0, 4.0); + System.out.println("Luas trapesium (alas1=3, alas2=5, tinggi=4): " + trapesium1.hitungLuas()); + + Trapesium trapesium2 = new Trapesium(4.0, 6.0, 5.0, 7.0); + System.out.println("Keliling trapesium (sisi1=4, sisi2=6, alas1=5, alas2=7): " + trapesium2.hitungKeliling()); + } +} diff --git a/src/H071211014/Pertemuan_5/Assignment_5_2.java b/src/H071211014/Pertemuan_5/Assignment_5_2.java new file mode 100644 index 0000000..734ceb6 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Assignment_5_2.java @@ -0,0 +1,19 @@ +package H071211014.Pertemuan_5; + +public class Assignment_5_2 { + + public static void main(String[] args) { + PengurusInti pi1 = new PengurusInti("Attar Musharih", "Ketua Umum", "Humas"); + pi1.tampilkanInfo(); + System.out.println(); + + KoordinatorBidang kb1 = new KoordinatorBidang("Budi", "Koordinator Bidang", "Web Development"); + kb1.tampilkanInfo(); + System.out.println(); + + Staf s1 = new Staf("Citra", "Staf Administrasi", 123); + s1.tampilkanInfo(); + + } + +} diff --git a/src/H071211014/Pertemuan_5/Assignment_5_3.java b/src/H071211014/Pertemuan_5/Assignment_5_3.java new file mode 100644 index 0000000..d85c4f1 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Assignment_5_3.java @@ -0,0 +1,16 @@ +package H071211014.Pertemuan_5; + +public class Assignment_5_3 { + public static void main(String[] args) { + Ikan ikan = new Ikan("Ikan Cupang", "Merah", "Pelet"); + Kucing kucing = new Kucing("Kucing Persia", "Putih", "Ikan"); + Burung burung = new Burung("Burung Merpati", "Abu-abu", "Biji-bijian"); + + ikan.displayInfo(); + System.out.println(); + kucing.displayInfo(); + System.out.println(); + burung.displayInfo(); + } + +} diff --git a/src/H071211014/Pertemuan_5/Balok.java b/src/H071211014/Pertemuan_5/Balok.java new file mode 100644 index 0000000..08ce6d1 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Balok.java @@ -0,0 +1,21 @@ +public class Balok extends BangunRuang { + double panjang, lebar, tinggi; + + public Balok(double panjang, double lebar, double tinggi) { + super("Balok"); + this.panjang = panjang; + this.lebar = lebar; + this.tinggi = tinggi; + } + + public double hitungVolume() { + double volume = panjang * lebar * tinggi; + return volume; + } + + @Override + public double hitungLuasPermukaan() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'hitungLuasPermukaan'"); + } +} diff --git a/src/H071211014/Pertemuan_5/BangunDatar.java b/src/H071211014/Pertemuan_5/BangunDatar.java new file mode 100644 index 0000000..4e17f6f --- /dev/null +++ b/src/H071211014/Pertemuan_5/BangunDatar.java @@ -0,0 +1,6 @@ +public abstract class BangunDatar { + public BangunDatar(String string) { + } + public abstract double hitungLuas(); + public abstract double hitungKeliling(); +} diff --git a/src/H071211014/Pertemuan_5/BangunRuang.java b/src/H071211014/Pertemuan_5/BangunRuang.java new file mode 100644 index 0000000..73da1cc --- /dev/null +++ b/src/H071211014/Pertemuan_5/BangunRuang.java @@ -0,0 +1,6 @@ +public abstract class BangunRuang { + public BangunRuang(String string) { + } + public abstract double hitungLuasPermukaan(); + public abstract double hitungVolume(); +} \ No newline at end of file diff --git a/src/H071211014/Pertemuan_5/Bola.java b/src/H071211014/Pertemuan_5/Bola.java new file mode 100644 index 0000000..70133b5 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Bola.java @@ -0,0 +1,19 @@ +public class Bola extends BangunRuang{ + double jari; + + public Bola(double jari) { + super("Bola"); + this.jari = jari; + } + + public double hitungVolume() { + double volume = 4 / 3 * Math.PI * jari * jari * jari; + return volume; + } + + @Override + public double hitungLuasPermukaan() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'hitungLuasPermukaan'"); + } +} diff --git a/src/H071211014/Pertemuan_5/Burung.java b/src/H071211014/Pertemuan_5/Burung.java new file mode 100644 index 0000000..d044550 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Burung.java @@ -0,0 +1,5 @@ +public class Burung extends Hewan{ + public Burung(String jenis, String warna, String makanan) { + super(jenis, 2, warna, makanan); + } +} diff --git a/src/H071211014/Pertemuan_5/Hewan.java b/src/H071211014/Pertemuan_5/Hewan.java new file mode 100644 index 0000000..ef6e0f5 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Hewan.java @@ -0,0 +1,20 @@ +public class Hewan { + String jenis; + int jumlahKaki; + String warna; + String makanan; + + public Hewan(String jenis, int jumlahKaki, String warna, String makanan) { + this.jenis = jenis; + this.jumlahKaki = jumlahKaki; + this.warna = warna; + this.makanan = makanan; + } + + public void displayInfo() { + System.out.println("Jenis: " + jenis); + System.out.println("Jumlah kaki: " + jumlahKaki); + System.out.println("Warna: " + warna); + System.out.println("Makanan: " + makanan); + } +} diff --git a/src/H071211014/Pertemuan_5/Ikan.java b/src/H071211014/Pertemuan_5/Ikan.java new file mode 100644 index 0000000..5ddd1a2 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Ikan.java @@ -0,0 +1,5 @@ +public class Ikan extends Hewan{ + public Ikan(String jenis, String warna, String makanan) { + super(jenis, 0, warna, makanan); + } +} diff --git a/src/H071211014/Pertemuan_5/KoordinatorBidang.java b/src/H071211014/Pertemuan_5/KoordinatorBidang.java new file mode 100644 index 0000000..b4ef9e9 --- /dev/null +++ b/src/H071211014/Pertemuan_5/KoordinatorBidang.java @@ -0,0 +1,13 @@ +public class KoordinatorBidang extends Anggota{ + String namaBidang; + + public KoordinatorBidang(String nama, String jabatan, String namaBidang) { + super(nama, jabatan); + this.namaBidang = namaBidang; + } + + public void tampilkanInfo() { + super.tampilkanInfo(); + System.out.println("Nama Bidang: " + namaBidang); + } +} diff --git a/src/H071211014/Pertemuan_5/Kubus.java b/src/H071211014/Pertemuan_5/Kubus.java new file mode 100644 index 0000000..514d25e --- /dev/null +++ b/src/H071211014/Pertemuan_5/Kubus.java @@ -0,0 +1,17 @@ +public class Kubus extends BangunRuang { + private double sisi; + + public Kubus(double sisi) { + this.sisi = sisi; + } + + @Override + public double hitungLuasPermukaan() { + return 6 * Math.pow(sisi, 2); + } + + @Override + public double hitungVolume() { + return Math.pow(sisi, 3); + } +} \ No newline at end of file diff --git a/src/H071211014/Pertemuan_5/Kucing.java b/src/H071211014/Pertemuan_5/Kucing.java new file mode 100644 index 0000000..f63a0cc --- /dev/null +++ b/src/H071211014/Pertemuan_5/Kucing.java @@ -0,0 +1,5 @@ +public class Kucing extends Hewan{ + public Kucing(String jenis, String warna, String makanan) { + super(jenis, 4, warna, makanan); + } +} diff --git a/src/H071211014/Pertemuan_5/Lingkaran.java b/src/H071211014/Pertemuan_5/Lingkaran.java new file mode 100644 index 0000000..e728301 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Lingkaran.java @@ -0,0 +1,18 @@ +public class Lingkaran extends BangunDatar { + private double radius; + + public Lingkaran(double radius) { + this.radius = radius; + } + + public double hitungLuas() { + return Math.PI * radius * radius; + } + + @Override + public double hitungKeliling() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'hitungKeliling'"); + } + +} diff --git a/src/H071211014/Pertemuan_5/PengurusInti.java b/src/H071211014/Pertemuan_5/PengurusInti.java new file mode 100644 index 0000000..e1a24b8 --- /dev/null +++ b/src/H071211014/Pertemuan_5/PengurusInti.java @@ -0,0 +1,14 @@ +public class PengurusInti extends Anggota { + String bidang; + + public PengurusInti(String nama, String jabatan, String bidang) { + super(nama, jabatan); + this.bidang = bidang; + } + + public void tampilkanInfo() { + super.tampilkanInfo(); + System.out.println("Bidang: " + bidang); + } + } + diff --git a/src/H071211014/Pertemuan_5/Persegi.java b/src/H071211014/Pertemuan_5/Persegi.java new file mode 100644 index 0000000..5f7622a --- /dev/null +++ b/src/H071211014/Pertemuan_5/Persegi.java @@ -0,0 +1,19 @@ +public class Persegi extends BangunDatar { + private double sisi; + + public Persegi(double sisi) { + this.sisi = sisi; + } + + @Override + public double hitungLuas() { + return Math.pow(sisi, 2); + } + + @Override + public double hitungKeliling() { + return 4 * sisi; + } +} + + diff --git a/src/H071211014/Pertemuan_5/PersegiPanjang.java b/src/H071211014/Pertemuan_5/PersegiPanjang.java new file mode 100644 index 0000000..2bd0708 --- /dev/null +++ b/src/H071211014/Pertemuan_5/PersegiPanjang.java @@ -0,0 +1,19 @@ +public class PersegiPanjang extends BangunDatar { + private double panjang; + private double lebar; + + public PersegiPanjang(double panjang, double lebar) { + this.panjang = panjang; + this.lebar = lebar; + } + + public double hitungLuas() { + return panjang * lebar; + } + + @Override + public double hitungKeliling() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'hitungKeliling'"); + } +} diff --git a/src/H071211014/Pertemuan_5/Segitiga.java b/src/H071211014/Pertemuan_5/Segitiga.java new file mode 100644 index 0000000..fa9c615 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Segitiga.java @@ -0,0 +1,22 @@ +public class Segitiga extends BangunDatar { + double alas, tinggi; + + public Segitiga(double alas, double tinggi) { + super("Segitiga"); + this.alas = alas; + this.tinggi = tinggi; + } + + public Segitiga(double d, double e, double f) { + } + + public double hitungLuas() { + return 0.5 * alas * tinggi; + } + + @Override + public double hitungKeliling() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'hitungKeliling'"); + } +} diff --git a/src/H071211014/Pertemuan_5/Staf.java b/src/H071211014/Pertemuan_5/Staf.java new file mode 100644 index 0000000..3929509 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Staf.java @@ -0,0 +1,13 @@ +public class Staf extends Anggota { + int id; + + public Staf(String nama, String jabatan, int id) { + super(nama, jabatan); + this.id = id; + } + + public void tampilkanInfo() { + super.tampilkanInfo(); + System.out.println("ID: " + id); + } +} diff --git a/src/H071211014/Pertemuan_5/Tabung.java b/src/H071211014/Pertemuan_5/Tabung.java new file mode 100644 index 0000000..d950f97 --- /dev/null +++ b/src/H071211014/Pertemuan_5/Tabung.java @@ -0,0 +1,20 @@ +public class Tabung extends BangunRuang{ + double jari, tinggi; + + public Tabung(double jari, double tinggi) { + super("Tabung"); + this.jari = jari; + this.tinggi = tinggi; + } + + public double hitungVolume() { + double volume = Math.PI * jari * jari * tinggi; + return volume; + } + + @Override + public double hitungLuasPermukaan() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'hitungLuasPermukaan'"); + } +} diff --git a/src/H071211014/Pertemuan_5/Trapesium.java b/src/H071211014/Pertemuan_5/Trapesium.java new file mode 100644 index 0000000..f2efe4b --- /dev/null +++ b/src/H071211014/Pertemuan_5/Trapesium.java @@ -0,0 +1,21 @@ +public class Trapesium { + double sisiAtas, sisiBawah, tinggi; + + public Trapesium(double sisiAtas, double sisiBawah, double tinggi, double d) { + super(); + this.sisiAtas = sisiAtas; + this.sisiBawah = sisiBawah; + this.tinggi = tinggi; + } + + public Trapesium(double d, double e, double f) { + } + + public double hitungLuas() { + return 0.5 * (sisiAtas + sisiBawah) * tinggi; + } + + public String hitungKeliling() { + return null; + } +} diff --git a/src/H071211014/Pertemuan_9/.gitattributes b/src/H071211014/Pertemuan_9/.gitattributes new file mode 100644 index 0000000..097f9f9 --- /dev/null +++ b/src/H071211014/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/H071211014/Pertemuan_9/.gitignore b/src/H071211014/Pertemuan_9/.gitignore new file mode 100644 index 0000000..1b6985c --- /dev/null +++ b/src/H071211014/Pertemuan_9/.gitignore @@ -0,0 +1,5 @@ +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build diff --git a/src/H071211014/Pertemuan_9/.vscode/settings.json b/src/H071211014/Pertemuan_9/.vscode/settings.json new file mode 100644 index 0000000..c5f3f6b --- /dev/null +++ b/src/H071211014/Pertemuan_9/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive" +} \ No newline at end of file diff --git a/src/H071211014/Pertemuan_9/AplikasiKalkulator/Main.java b/src/H071211014/Pertemuan_9/AplikasiKalkulator/Main.java new file mode 100644 index 0000000..ef9bb51 --- /dev/null +++ b/src/H071211014/Pertemuan_9/AplikasiKalkulator/Main.java @@ -0,0 +1,81 @@ +public class Main { + public static void main(String[] args) { + private TextField display; + + @Override + public void start(Stage primaryStage) { + primaryStage.setTitle("JavaFX Calculator"); + + + GridPane grid = new GridPane(); + grid.setPadding(new Insets(10, 10, 10, 10)); + grid.setVgap(5); + grid.setHgap(5); + + + display = new TextField(); + display.setPrefHeight(30); + display.setEditable(false); + GridPane.setColumnSpan(display, 4); + grid.getChildren().add(display); + + + String[] kalkulator1 = "Masukkan angka"; + String[] kalkulator2 = "Masukkan angka"; + + + + int row = 1; + int col = 0; + + + for (String label : buttonLabels) { + Button button = new Button(label); + button.setPrefHeight(30); + button.setPrefWidth(30); + + // Menambahkan event handler untuk tombol + button.setOnAction(event -> { + String currentText = display.getText(); + String buttonText = button.getText(); + + // Menghandle tombol "=" untuk melakukan perhitungan + if (buttonText.equals("=")) { + try { + double result = evaluateExpression(currentText); + display.setText(Double.toString(result)); + } catch (Exception e) { + display.setText("Error"); + } + } else { + display.setText(currentText + buttonText); + } + }); + + grid.add(button, col, row); + + // Mengatur posisi tombol pada GridPane + col++; + if (col > 3) { + col = 0; + row++; + } + } + + Scene scene = new Scene(grid, 160, 200); + primaryStage.setScene(scene); + primaryStage.show(); + } + + private double evaluateExpression(String expression) { + + javax.script.ScriptEngineManager mgr = new javax.script.ScriptEngineManager(); + javax.script.ScriptEngine engine = mgr.getEngineByName("JavaScript"); + try { + Object result = engine.eval(expression); + return (double) result; + } catch (Exception e) { + throw new RuntimeException("Error evaluating expression: " + expression, e); + } + } +} diff --git a/src/H071211014/Pertemuan_9/AplikasiKalkulator/TestJavaFx.java b/src/H071211014/Pertemuan_9/AplikasiKalkulator/TestJavaFx.java new file mode 100644 index 0000000..3a872fe --- /dev/null +++ b/src/H071211014/Pertemuan_9/AplikasiKalkulator/TestJavaFx.java @@ -0,0 +1,18 @@ +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.stage.Stage; +import javafx.scene.layout.VBox; +import javafx.geometry.Pos; +import javafx.scene.control.Button; + +public class TestJavaFx { + Button btn = new Button("Dont Click"); + VBox vbox = new VBox(); + vbox.getChildren().add(btn); + vbox.setAlignment(Pos.CENTER); + Scene scene = new Scene(vbox, 600, 300); + stage.setScene(scene); + stage.setTitle("Example"); + stage.show(); + +} diff --git a/src/H071211014/Pertemuan_9/AplikasiKalkulator/TextFieldExperiments.java b/src/H071211014/Pertemuan_9/AplikasiKalkulator/TextFieldExperiments.java new file mode 100644 index 0000000..493c15c --- /dev/null +++ b/src/H071211014/Pertemuan_9/AplikasiKalkulator/TextFieldExperiments.java @@ -0,0 +1,28 @@ +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +public class TextFieldExperiments extends Application { +@Override +public void start(Stage primaryStage) throws Exception { +primaryStage.setTitle("HBox Experiment 1"); +TextField textField = new TextField(); +Label label = new Label("My Label"); +Button button = new Button("Click to get text"); +button.setOnAction(action -> { +label +.setText("Halo perkenalkan saya " + textField +.getText()); +}); +VBox vbox = new VBox(label, textField, button); +Scene scene = new Scene(vbox, 200, 100); +primaryStage.setScene(scene); +primaryStage.show(); +} +public static void main(String[] args) { +Application.launch(args); +} +} \ No newline at end of file diff --git a/src/H071211014/Pertemuan_9/app/build.gradle b/src/H071211014/Pertemuan_9/app/build.gradle new file mode 100644 index 0000000..1f9611b --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/build.gradle @@ -0,0 +1,48 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This generated file contains a sample Java application project to get you started. + * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle + * User Manual available at https://docs.gradle.org/8.1.1/userguide/building_java_projects.html + */ + +plugins { + // Apply the application plugin to add support for building a CLI application in Java. + id 'application' + id 'org.openjfx.javafxplugin' version '0.0.14' +} + +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' +} + +javafx { + version = "20" + modules = [ 'javafx.controls' ] +} + +// Apply a specific Java toolchain to ease working on different environments. +java { + toolchain { + languageVersion = JavaLanguageVersion.of(20) + } +} + +application { + // Define the main class for the application. + mainClass = 'hellotest.App' +} + +tasks.named('test') { + // Use JUnit Platform for unit tests. + useJUnitPlatform() +} diff --git a/src/H071211014/Pertemuan_9/app/src/main/java/App.java b/src/H071211014/Pertemuan_9/app/src/main/java/App.java new file mode 100644 index 0000000..53bb9ed --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/main/java/App.java @@ -0,0 +1,23 @@ +/* + * This Java source file was generated by the Gradle 'init' task. + */ + +package hellotest; + +import javafx.application.Application; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; + +public class App { + public String getGreeting() { + return "Hello World!"; + } + + public static void main(String[] args) { + System.out.println(new App().getGreeting()); + } +} diff --git a/src/H071211014/Pertemuan_9/app/src/main/java/String.java b/src/H071211014/Pertemuan_9/app/src/main/java/String.java new file mode 100644 index 0000000..3483798 --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/main/java/String.java @@ -0,0 +1,4 @@ + +public class String { + +} diff --git a/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/ActionEvent.java b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/ActionEvent.java new file mode 100644 index 0000000..aa4d7b7 --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/ActionEvent.java @@ -0,0 +1,5 @@ +package hellotest; + +public class ActionEvent { + +} diff --git a/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Application.java b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Application.java new file mode 100644 index 0000000..1b64561 --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Application.java @@ -0,0 +1,5 @@ +package hellotest; + +public class Application { + +} diff --git a/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Button.java b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Button.java new file mode 100644 index 0000000..c44783b --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Button.java @@ -0,0 +1,11 @@ +package hellotest; + +public class Button { + + public void setText(java.lang.String string) { + } + + public void setOnAction(EventHandler eventHandler) { + } + +} diff --git a/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/EventHandler.java b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/EventHandler.java new file mode 100644 index 0000000..2ee8811 --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/EventHandler.java @@ -0,0 +1,5 @@ +package hellotest; + +public class EventHandler { + +} diff --git a/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Override.java b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Override.java new file mode 100644 index 0000000..5501c50 --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Override.java @@ -0,0 +1,5 @@ +package hellotest; + +public @interface Override { + +} diff --git a/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Scene.java b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Scene.java new file mode 100644 index 0000000..30ce879 --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/Scene.java @@ -0,0 +1,5 @@ +package hellotest; + +public class Scene { + +} diff --git a/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/StackPane.java b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/StackPane.java new file mode 100644 index 0000000..530a032 --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/StackPane.java @@ -0,0 +1,5 @@ +package hellotest; + +public class StackPane { + +} diff --git a/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/String.java b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/String.java new file mode 100644 index 0000000..592e4a2 --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/String.java @@ -0,0 +1,5 @@ +package hellotest; + +public class String { + +} diff --git a/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/System.java b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/System.java new file mode 100644 index 0000000..31e16d9 --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/main/java/hellotest/System.java @@ -0,0 +1,10 @@ +package hellotest; + +public class System { + + protected static Object out; + + public class out { + } + +} diff --git a/src/H071211014/Pertemuan_9/app/src/test/java/hellotest/AppTest.java b/src/H071211014/Pertemuan_9/app/src/test/java/hellotest/AppTest.java new file mode 100644 index 0000000..3a09867 --- /dev/null +++ b/src/H071211014/Pertemuan_9/app/src/test/java/hellotest/AppTest.java @@ -0,0 +1,17 @@ +/* + * This Java source file was generated by the Gradle 'init' task. + */ +package hellotest; + +import org.junit.jupiter.api.Test; + +import App; + +import static org.junit.jupiter.api.Assertions.*; + +class AppTest { + @Test void appHasAGreeting() { + App classUnderTest = new App(); + assertNotNull(classUnderTest.getGreeting(), "app should have a greeting"); + } +} diff --git a/src/H071211014/Pertemuan_9/gradle/wrapper/gradle-wrapper.properties b/src/H071211014/Pertemuan_9/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..37aef8d --- /dev/null +++ b/src/H071211014/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/H071211014/Pertemuan_9/gradlew b/src/H071211014/Pertemuan_9/gradlew new file mode 100644 index 0000000..aeb74cb --- /dev/null +++ b/src/H071211014/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/H071211014/Pertemuan_9/gradlew.bat b/src/H071211014/Pertemuan_9/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/src/H071211014/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/H071211014/Pertemuan_9/settings.gradle b/src/H071211014/Pertemuan_9/settings.gradle new file mode 100644 index 0000000..57fe374 --- /dev/null +++ b/src/H071211014/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 = 'JavaFX' +include('app')