Rabu, 27 November 2019

Kuis POS - Point of Sales

Tugas Kuis POS
Sebelum diisi

Sesudah diisi (output)
 import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.text.*;
import javafx.scene.text.Text.*;
import javafx.stage.Stage;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.collections.*;
public class pointof extends Application
{
    int hargaitung;
    @Override
    public void start (Stage stage) throws Exception
    {
     
        GridPane gridPane = new GridPane();
        gridPane.setMinSize(200, 200);
        gridPane.setPadding(new Insets(10, 10, 10, 10));
        gridPane.setVgap(5);
        gridPane.setHgap(5);
     
        Text LabelKasir = new Text ("Kasir \t\t");
        Text LabelNama = new Text ("Nama Barang \t\t");
        Text LabelHarga = new Text ("Harga Satuan \t\t");
        Text LabelJumlah = new Text ("Jumlah \t\t");
     
        Button cetak = new Button("Cetak");
        Text welcome = new Text("Welcome to PoS");
        TextField NamaKasir = new TextField();
        TextField NamaBarang = new TextField();
        TextField HargaBarang = new TextField();
        TextField JumlahBarang = new TextField();
        Text HargaTotal = new Text();
        gridPane.add(welcome, 0, 0);
        gridPane.add(LabelKasir, 0, 1);
        gridPane.add(LabelNama, 0, 2);
        gridPane.add(LabelHarga, 0, 3);
        gridPane.add(LabelJumlah, 0, 4);
     
        gridPane.add(cetak,3,8);
        gridPane.add(NamaKasir, 2,1);
        gridPane.add(NamaBarang, 2,2);
        gridPane.add(HargaBarang, 2,3);
        gridPane.add(JumlahBarang, 2,4);
     
        EventHandler<ActionEvent> ebutton = new EventHandler<ActionEvent>()
        {
            public void handle(ActionEvent e)
            {
                VBox box = new VBox();
                box.setPadding(new Insets(20));
                box.setSpacing(20);
                box.setAlignment(Pos.TOP_LEFT);
             
                Text msgEnd = new Text("Terimakasih Sudah Berbelanja");
                Text namaKasirEnd = new Text("Nama Kasir\t: " +NamaKasir.getText());
                Text namaBarangEnd = new Text("Nama Barang\t: "+NamaBarang.getText());
                Text jumlahBarangEnd = new Text("Jumlah Barang\t: "+JumlahBarang.getText());
                Text hargaSatuanEnd = new Text("Harga Barang\t: " +HargaBarang.getText());
                Text hargaTotalEnd = new Text("Total Bayar\t: Rp. "+Integer.parseInt(JumlahBarang.getText()) * Integer.parseInt(HargaBarang.getText()));
             
                box.getChildren().add(msgEnd);
                box.getChildren().add(namaKasirEnd);
                box.getChildren().add(namaBarangEnd);
                box.getChildren().add(jumlahBarangEnd);
                box.getChildren().add(hargaSatuanEnd);
                box.getChildren().add(hargaTotalEnd);
             
                Scene scene1= new Scene(box,500,500);
                stage.setTitle (" Point Of Sales");
                stage.setScene(scene1);
                stage.show();
            }
        };
        cetak.setOnAction(ebutton);
     
     
        Scene scene= new Scene(gridPane,700,700);
        stage.setTitle (" Point Of Sales");
        stage.setScene(scene);
    stage.show();
    }
}


Tidak ada komentar:

Posting Komentar