Software Tester Manajemen Model

27 3. Tabel BarangPredik Gambar 4.3 : Tabel BarangPredik Gambar 4.3 diatas, merupakan table dari BarangPredik beserta keterangannya. Tabel BarangPredik merupakan tabel bantu untuk program yang telah dibuat. Fungsi dari tabel ini adalah menyimpan sementara data penjualan dan hasil prediksi untuk mempermudah penghitungan MAPE. Tabel ini memiliki 3 kolom, yaitu kolom no, penjualan, prediksi.

4.2 Manajemen Model

4.2.1 Software Tester

Berikut adalah fungsi-fungsi dan tahapan-tahapan peramalan pada software tester : 1. Button Prediksi Merupakan sebuah tombol untuk melakukan prediksi dari data- data yang telah dimasukkan. Pada tombol prediksi dibagi menjadi 3 kondisi sesuai dengan mode peramalan yang telah dipilih sebelumnya. Langkah fungsi buttonPrediksi dalam melakukan prediksi peramalan adalah sebagai berikut : a. Melakukan peramalan public void hitungMAsimulasiClass sm throws SQLException { int[] windowSizes = {sm.getVar}; double[] data = {sm.getJan1, sm.getFeb1, sm.getMar1, sm.getApr1, sm.getMei1, sm.getJun1, sm.getJul1, sm.getAgt1, sm.getSep1, sm.getOkt1, sm.getNov1, sm.getDes1, sm.getJan2, sm.getFeb2, sm.getMar2, sm.getApr2, sm.getMei2, sm.getJun2, sm.getJul2, 28 sm.getAgt2, sm.getSep2, sm.getOkt2, sm.getNov2, sm.getDes2}; int i = 1; for int windSize : windowSizes { MA ma = new MAwindSize; for double x : data { if x = 0 { sm.setNoi; ma.newNumx; sm.setDatax; double p = ma.getAvg; System.out.printlnNext number = + x + , SMA = + p; sm.setPrediksip; simulasiDB.getKoneksi.catatPrediksm; } i++; } } } b. Menghitung dengan algoritma moving average package testerPack; import java.util.LinkedList; import java.util.Queue; public class MA { private final QueueDouble window = new LinkedListDouble; private final int period; private double sum; 29 public MAint period { assert period 0 : Period must be a positive integer; this.period = period; } public void newNumdouble num { sum += num; window.addnum; if window.size period { sum -= window.remove; } } public double getAvg { if window.isEmpty { return 0; technically the average is undefined } return sum window.size; } } c. Memasukkan hasil prediksi kedalam tabel bantu public void catatPrediksimulasiClass sim throws SQLException { PreparedStatement pstmt = null; try { conn.setAutoCommitfalse; String sql = update barangPredik set penjualan=? ,prediksi=? + where no=?; pstmt = conn.prepareStatementsql; 30 pstmt.setDouble3, sim.getNo; pstmt.setDouble2, sim.getPrediksi; pstmt.setDouble1, sim.getData; pstmt.executeUpdate; conn.commit; } catch SQLException exception { conn.rollback; throw exception; } finally { try { conn.setAutoCommittrue; if pstmt = null { pstmt.close; } } catch SQLException exception { throw exception; } } } d. Mencari prediksi public void cariPredik1simulasiClass sim throws SQLException { PreparedStatement statement = null; ResultSet result = null; String p = ; try { conn.setAutoCommitfalse; String sql = Select prediksi from barangPredik where + no=?; statement = 31 conn.prepareStatementsql; statement.setInt1, sim.getBulan + 2; result = statement.executeQuery; if result.next { p = result.getStringprediksi; Double pr = Double.parseDoublep; sim.setPrediksipr; } conn.commit; } catch SQLException exception { conn.rollback; throw exception; } } public void cariPredik2simulasiClass sim throws SQLException { PreparedStatement statement = null; ResultSet result = null; String p = ; try { conn.setAutoCommitfalse; String sql = Select prediksi from barangPredik where + no=?; statement = conn.prepareStatementsql; statement.setInt1, sim.getBulan + 1; 32 result = statement.executeQuery; if result.next { p = result.getStringprediksi; Double pr = Double.parseDoublep; sim.setPrediksipr; } conn.commit; } catch SQLException exception { conn.rollback; throw exception; } } public void cariPredik3simulasiClass sim throws SQLException { PreparedStatement statement = null; ResultSet result = null; String p = ; try { conn.setAutoCommitfalse; String sql = Select prediksi from barangPredik where + no=?; statement = conn.prepareStatementsql; statement.setInt1, sim.getBulan; result = statement.executeQuery; if result.next { 33 p = result.getStringprediksi; Double pr = Double.parseDoublep; sim.setPrediksipr; } conn.commit; } catch SQLException exception { conn.rollback; throw exception; } } e. Mencari MAPE dan menampilkan hasil public void mapeNormalsimulasiClass sm throws SQLException { int setno = sm.getNo - 6; int jum = 0; sm.setNosetno; sm.setMAPE0; for int j = 0; j 6; j++ { simulasiDB.getKoneksi.cariSelisihsm; int no = sm.getNo + 1; sm.setNono; int mape = sm.getMAPE; jum = jum + mape; sm.setJumjum; System.out.printlnno : + no + mape : + sm.getMAPE + jumlah Mape: + sm.getJum; } int mapes = sm.getJum 6; 34 sm.setJummapes; sm.setHasilHasil prediksi untuk bulan + sm.getNamaBulan + tahun + sm.getTahun + \n adalah + sm.getPrediksi + \n MAPE : + sm.getJum + ; } public void mapeVar1simulasiClass sm throws SQLException { simulasiDB.getKoneksi.cariPredik1sm; int setno = sm.getBulan + 6; int jum = 0; sm.setNosetno; sm.setMAPE0; for int j = 0; j 6; j++ { simulasiDB.getKoneksi.cariSelisih1sm; int no = sm.getNo + 1; sm.setNono; int mape = sm.getMAPE; jum = jum + mape; sm.setJumjum; System.out.printlnno : + no + mape : + sm.getMAPE + jumlah Mape: + sm.getJum; } int mapes = sm.getJum 6; sm.setJummapes; sm.setHasilHasil prediksi untuk bulan + sm.getNamaBulan 35 + tahun + sm.getTahun + \n adalah + sm.getPrediksi + \n MAPE : + sm.getJum + ; } public void mapeVar2simulasiClass sm throws SQLException { simulasiDB.getKoneksi.cariPredik2sm; int setno = sm.getBulan + 6; int jum = 0; sm.setNosetno; sm.setMAPE0; for int j = 0; j 6; j++ { simulasiDB.getKoneksi.cariSelisih2sm; int no = sm.getNo + 1; sm.setNono; int mape = sm.getMAPE; jum = jum + mape; sm.setJumjum; System.out.printlnno : + no + mape : + sm.getMAPE + jumlah Mape: + sm.getJum; } int mapes = sm.getJum 6; sm.setJummapes; sm.setHasilHasil prediksi untuk bulan + sm.getNamaBulan + tahun + sm.getTahun + \n adalah + sm.getPrediksi + \n MAPE : + sm.getJum + 36 ; } public void mapeVar3simulasiClass sm throws SQLException { simulasiDB.getKoneksi.cariPredik3sm; int setno = sm.getBulan + 6; int jum = 0; sm.setNosetno; sm.setMAPE0; for int j = 0; j 6; j++ { simulasiDB.getKoneksi.cariSelisih3sm; int no = sm.getNo + 1; sm.setNono; int mape = sm.getMAPE; jum = jum + mape; sm.setJumjum; System.out.printlnno : + no + mape : + sm.getMAPE + jumlah Mape: + sm.getJum; } int mapes = sm.getJum 6; sm.setJummapes; sm.setHasilHasil prediksi untuk bulan + sm.getNamaBulan + tahun + sm.getTahun + \n adalah + sm.getPrediksi + \n MAPE : + sm.getJum + ; } } 37 f. Mencari selisih error public void cariSelisihsimulasiClass sim throws SQLException { PreparedStatement statement = null; ResultSet result = null; int p = 0; try { conn.setAutoCommitfalse; String sql = select ABSselect penjualan from barangpredik + where no=?-select prediksi from + barangpredik where no=?select penjualan + from barangpredik where no=?100 as MAPE from dual; statement = conn.prepareStatementsql; statement.setInt1, sim.getNo + 1; statement.setInt2, sim.getNo; statement.setInt3, sim.getNo + 1; result = statement.executeQuery; if result.next { p = result.getIntmape; sim.setMAPEp; } conn.commit; } catch SQLException exception { conn.rollback; throw exception; 38 } } public void cariSelisih1simulasiClass sim throws SQLException { PreparedStatement statement = null; ResultSet result = null; int p = 0; try { conn.setAutoCommitfalse; String sql = select ABSselect penjualan from barangpredik + where no=?-select prediksi from + barangpredik where no=?select penjualan + from barangpredik where no=?100 as MAPE from dual; statement = conn.prepareStatementsql; statement.setInt1, sim.getNo; statement.setInt2, sim.getNo - 10; statement.setInt3, sim.getNo; result = statement.executeQuery; if result.next { p = result.getIntmape; sim.setMAPEp; } conn.commit; } catch SQLException exception { conn.rollback; 39 throw exception; } } public void cariSelisih2simulasiClass sim throws SQLException { PreparedStatement statement = null; ResultSet result = null; int p = 0; try { conn.setAutoCommitfalse; String sql = select ABSselect penjualan from barangpredik + where no=?-select prediksi from + barangpredik where no=?select penjualan + from barangpredik where no=?100 as MAPE from dual; statement = conn.prepareStatementsql; statement.setInt1, sim.getNo; statement.setInt2, sim.getNo - 11; statement.setInt3, sim.getNo; result = statement.executeQuery; if result.next { p = result.getIntmape; sim.setMAPEp; } conn.commit; } catch SQLException exception { 40 conn.rollback; throw exception; } } public void cariSelisih3simulasiClass sim throws SQLException { PreparedStatement statement = null; ResultSet result = null; int p = 0; try { conn.setAutoCommitfalse; String sql = select ABSselect penjualan from barangpredik + where no=?-select prediksi from + barangpredik where no=?select penjualan + from barangpredik where no=?100 as MAPE from dual; statement = conn.prepareStatementsql; statement.setInt1, sim.getNo; statement.setInt2, sim.getNo - 12; statement.setInt3, sim.getNo; result = statement.executeQuery; if result.next { p = result.getIntmape; sim.setMAPEp; } conn.commit; 41 } catch SQLException exception { conn.rollback; throw exception; } } 2. Button Batal Merupakan sebuah tombol yang akan mengembalikan semua text field dalam sistem simulasi menjadi bersih kembali sehingga tidak harus menghapusnya satu persatu. 3. Button Keluar Merupakan sebuah tombol yang fungsinya adalah untuk menutup sistem.

4.2.2 Software User