Classes and Objects Muhammad Izzuddin A (05111740000035) Kelas B A. Time class study (Fig 8.1 - 8.2) Class yang dibuat: Time1 dan Time1Test Overview class diagram: Berikut source code dari kelas Time1 : /** * Program Kelas Time1 (Fig. 8.1) * Deklarasi Kelas Time1, mengelola waktu dalam format 24h * * @author Muhammad Izzuddin A */ public class Time1 { // instance variables - replace the example below with your own private int hour; private int minute; private int second; /** * Setter method * @param h hour * @param m minute * @param s second */ public void setTime(int h, int m, int s) { if ((h >= 0 && h < 24) && (m >= 0 && m < 60) && (s >= 0 && s < 60)){ hour = h; minute = m; second = s; } else { throw new IllegalArgumentException("Hour, Minute and/or Second was out of range");...
Muhammad Izzuddin Al Islami 05111740000035 Applet dan JavaFX Applet Applet adalah sebuah tipe program yang dapat diletakkan dalam sebuah webpage sebagai dynamic content. Applet akan dijalankan oleh browser dan bekerja pada sisi client. Contoh program Hello World dalam applet java: import java.awt.*; import javax.swing.*; /** * Class HelloWorld - write a description of the class here * * @author Izzud * @version v0.Hello */ public class TesApplet extends java.applet.Applet { public void paint(Graphics g){ int fontSize = 20; Font f = new Font("SansSerif", Font.BOLD, fontSize); g.setFont(f); g.setColor(Color.BLACK); int xCent = this.getSize().width/2; int yCent = this.getSize().height/2; String str = "Hello Java Applet"; FontMetrics fm = this.getFontMetrics(f); int wordXPos = xCent - (fm.stringWidth(str)/2); g.drawString(str, wordXPos, yCent); } } Output...
Comments
Post a Comment