Sabtu, 29 September 2018

PBO A-Tugas Latihan Membuat Jam

Nama: Ayu Mutiara Sari
NRP: 05111740000149
Kelas: PBO A

1. Source Code NumberDisplay


 /**  
  * Write a description of class NumberDisplay here.  
  *  
  * @author (Ayu Mutiara Sari)  
  * @version (24.01)  
  */  
 public class NumberDisplay    
  {    
   private int limit;    
   private int nilai;    
   public NumberDisplay(int Maksimal)    
   {    
   limit = Maksimal;    
   nilai = 0;    
   }    
   public int getValue()    
   {    
   return nilai;    
   }    
   public void increment()    
   {    
   nilai = (nilai + 1) % limit;    
   }    
   public String getDisplayValue()    
   {    
   if(nilai < 10)    
   {    
    return "0" + nilai;    
   }    
   else    
   {    
    return "" + nilai;    
   }    
   }    
   public void setValue(int replacementValue)    
   {    
   if((replacementValue >= 0) && (replacementValue < limit))    
   {    
    nilai = replacementValue;    
   }    
   }    
  }    

2. Source Code ClockDisplay


 /**  
  * Write a description of class ClockDisplay here.  
  *  
  * @author (Ayu Mutiara Sari)  
  * @version (24.01)  
  */  
 public class ClockDisplay    
  {    
   private NumberDisplay jam;    
   private NumberDisplay menit;    
   private String displayString;   
   public ClockDisplay()    
   {    
   jam = new NumberDisplay(24);    
   menit = new NumberDisplay(60);    
   updateDisplay();    
   }    
   public ClockDisplay(int hour, int minute)    
   {    
   jam = new NumberDisplay(24);    
   menit = new NumberDisplay(60);    
   setTime(hour,minute);    
   }    
   public void timeTick()    
   {    
   menit.increment();    
   if(menit.getValue() == 0)    
   {    
    jam.increment();    
   }    
   updateDisplay();    
   }    
   public void setTime(int hour, int minute)    
   {    
   jam.setValue(hour);    
   menit.setValue(minute);    
   updateDisplay();    
   }    
   public String getTime()    
   {    
   return displayString;    
   }    
   private void updateDisplay()    
   {    
   displayString = jam.getDisplayValue() + ":" + menit.getDisplayValue();    
   }    
  }    

3. Source Code


 /**  
  * Write a description of class TestClockDisplay here.  
  *  
  * @author (Ayu Mutiara Sari)  
  * @version (24.01)  
  */  
 public class TestClockDisplay    
  {    
   public TestClockDisplay()    
   {    
   }    
   public void test()    
   {    
   ClockDisplay clock = new ClockDisplay();    
   clock.setTime(00,06);    
   System.out.println(clock.getTime());    
   clock.setTime(04,30);    
   System.out.println(clock.getTime());  
   clock.setTime(12,10);    
   System.out.println(clock.getTime());  
   clock.setTime(22,59);    
   System.out.println(clock.getTime());   
   }    
  }    

4. Source Code Clock


 /**  
  * Write a description of class Clock here.  
  *  
  * @author (Ayu Mutiara Sari)  
  * @version (24.01)  
  */  
 import java.awt.*;    
  import java.awt.event.*;    
  import javax.swing.*;    
  import javax.swing.border.*;    
  public class Clock    
  {    
   private JFrame frame;    
   private JLabel label;    
   private ClockDisplay clock;    
   private boolean clockOn = false;    
   private TimerThread timerThread;    
   public void Clock()    
   {    
   makeFrame();    
   clock = new ClockDisplay();    
   }    
   private void start()    
   {    
   clockOn = true;    
   timerThread = new TimerThread();    
   timerThread.start();    
   }    
   private void stop()    
   {    
   clockOn = false;    
   }    
   private void step()    
   {    
   clock.timeTick();    
   label.setText(clock.getTime());    
   }    
   private void showAbout()    
   {    
   JOptionPane.showMessageDialog (frame, "Clock Version 0.1\n" +    
   "Membuat jam digital simpel dengan Java.",    
   "About Clock",    
   JOptionPane.INFORMATION_MESSAGE);    
   }    
   private void quit()    
   {    
   System.exit(0);    
   }    
   private void makeFrame()    
   {    
   frame = new JFrame("Clock");    
   JPanel contentPane = (JPanel)frame.getContentPane();    
   contentPane.setBorder(new EmptyBorder(1,60,1,60));    
   makeMenuBar(frame);    
   contentPane.setLayout(new BorderLayout(12,12));    
   label = new JLabel("00:00", SwingConstants.CENTER);    
   Font displayFont = label.getFont().deriveFont(96.0f);    
   label.setFont(displayFont);    
   contentPane.add(label, BorderLayout.CENTER);    
   JPanel toolbar = new JPanel();    
   toolbar.setLayout(new GridLayout(1,0));    
   JButton startButton = new JButton("Start");    
   startButton.addActionListener(e->start());    
   toolbar.add(startButton);    
   JButton stopButton = new JButton("Stop");    
   stopButton.addActionListener(e->stop());    
   toolbar.add(stopButton);    
   JButton stepButton = new JButton("Step");    
   stepButton.addActionListener(e->step());    
   toolbar.add(stepButton);    
   JPanel flow = new JPanel();    
   flow.add(toolbar);    
   contentPane.add(flow, BorderLayout.SOUTH);    
   frame.pack();    
   Dimension d = Toolkit.getDefaultToolkit().getScreenSize();    
   frame.setLocation(d.width/2 - frame.getWidth()/2, d.height/2 - frame.getHeight()/2);    
   frame.setVisible(true);    
   }    
   private void makeMenuBar(JFrame frame)    
   {    
   final int SHORTCUT_MASK =    
   Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();    
   JMenuBar menubar = new JMenuBar();    
   frame.setJMenuBar(menubar);    
   JMenu menu;    
   JMenuItem item;    
   menu = new JMenu("File");    
   menubar.add(menu);    
   item = new JMenuItem("About Clock...");    
    item.addActionListener(e->showAbout());    
   menu.add(item);    
   menu.addSeparator();    
   item = new JMenuItem("Quit");    
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,SHORTCUT_MASK));    
    item.addActionListener(e->quit());    
   menu.add(item);    
   }    
   class TimerThread extends Thread    
   {    
   public void run()    
    {    
    while(clockOn)    
    {    
     step();    
     pause();    
    }    
    }    
    private void pause()    
    {    
    try    
    {    
     Thread.sleep(900);    
    }    
    catch(InterruptedException exc)    
    {    
    }    
   }    
   }    
  }   

Hasil:



Selasa, 25 September 2018

PWEBC- TUGAS BERITA

Nama: Ayu Mutiara Sari
NRP: 05111740000149
Kelas: PWEB C
source: www.techinasia.com

code HTML:

 <!DOCTYPE html>   
  <html>   
  <head>   
    <title>Tech in Asia</title>   
    <link rel="stylesheet" href="yeay.css"/>   
  </head>   
  <body>   
    <div class="header">   
    <div class="menu1">   
       <ul>   
         <li><a href="#">NEWS</a></li>   
         <li><a href="#">JOBS</a></li>   
         <li><a href="#">COMPANIES</a></li>   
         <li><a href="#">EVENT</a></li>   
         <li><a href="#">ABOUT</a></li>   
         <li><a href="#">ADVERTISE</a></li>   
       </ul>   
    </div>   
    <div class="menu2">   
       <ul>   
         <li><a href="#">CATEGORIES</a></li>   
         <li><a href="#">MARKETS</a></li>   
         <li><a href="#">WRITERS</a></li>   
       </ul>   
    </div>   
    </div>   
    <div class="isi">   
       <div class="jarak">    
         <div class="kiri">  
         <div class="border">   
            <div class="jarak">   
              <img src="web1.jpg" style=" float: left; width: 280px;height: 200px;">   
              <h3>How one Silicon Valley investor helps US startups enter Japan</h3>   
              <p>Hire the right country manager.</p>   
              <button class="btn">Read More..</button>   
            </div>   
         </div>   
            <div class="border">   
            <div class="jarak">   
              <img src="web3.jpg" style="float: left;width: 280px;0height: 200px;">   
              <h3>I oversee government digital services at GovTech. Ask me anything!</h3>   
              <p>Before GovTech, Parimal was director of technology at DreamWorks Animation. Ask him anything!</p>   
              <button class="btn">Read More..</button>   
            </div>   
         </div>  
         <div class="border">   
            <div class="jarak">   
              <img src="web2.jpg" style="float: left;width: 280px;height: 200px;">   
              <h3>Singapore introduces new rules for bike-share users, fines for abusers</h3>   
              <p>The rules are part of the Land Transport Authority’s new licensing regime for bike-sharing services.</p>   
              <button class="btn">Read More..</button>   
            </div>   
         </div>    
         </div>     
         <div class="job">   
            <div class="jarak">   
              <h2>LATEST JOBS</h2>   
                 <img src="job1.png" style="float: left;width: 34px;height: 34px;">   
                 <h1>Software Engineer-Backend</h1>   
                 <p>Jakarta, Indonesia</p>   
                 <img src="job2.png" style="float: left;width: 34px;height: 34px;">   
                 <h1>Graphic Designer</h1>   
                 <p>Singapore, Singapore</p>   
                 <img src="job3.png" style="float: left;width: 34px;height:34px;">   
                 <h1>Senior NodeJs Developer</h1>   
                 <p>Singapore, Singapore</p>    
            </div>   
            <div class="footer" >   
              <h2>Copyright 2018 PwebC</h2>   
            </div>   
         </div>   
       </div>   
    </div>   
  </body>   
  </html>  

code css:
 body{   
    background: #FF7F50;   
    color: #333;   
  /*   width: 100% ;   
    height: 100%;*/   
    font-family: "lato", cursive, sans-serif;   
    /*margin: 0 auto;*/   
  }   
  .isi{   
    width: 88%;   
    margin: auto;   
    /*height: 420px;*/   
    padding: 0.1px;   
    background: #FFF8DC;   
    color: #333;   
  }   
  .header{   
    margin: 0;   
    background: #FFF8DC;   
  }   
  .kiri{   
    width: 70%;   
    float: left;   
    margin: auto;   
    background: #FFF8DC;   
    /*height: 420px;*/   
  }   
  .job{   
    width: 25%;   
    float: left;   
    margin: auto;   
    background: #FFF8DC;   
    /*height: 420px;*/   
  }   
  .border{   
    /*border: 2px solid #000;*/   
    height: 200px;   
    margin-top: 1pc;   
    padding-bottom: 3pc;   
    padding-right: 2pc;   
  }   
  .undecor{   
    text-decoration: none;   
  }   
  .footer{   
    /*width: 90%;*/   
    margin: auto;   
    height: 40px;   
    line-height: 40px;   
    background: #F0EEEE;   
  }   
  .menu1{   
    background-color: #F0EEEE;   
    height: 50px;   
    line-height: 50px;   
    /*position: relative;*/   
    /*width: 90%;*/   
    /*margin: 0;*/   
    /*padding:0;*/   
  }   
  .menu2{   
    background-color: #F0EEEE;   
    height: 60px;   
    line-height: 60px;   
    /*position: relative;*/   
    /*width: 90%;*/   
    margin: 0;   
    /*padding:0 auto;*/   
  }   
  .jarak{   
    padding: 0 2pc;   
  }   
  .menu1 ul{   
    list-style: none;   
  }   
  .menu1 ul li a{   
    float: left;   
    width: 14%;   
    display: block;   
    text-align: center;   
    color: #A4A4A4;   
    text-decoration: none;   
  }   
  .menu1 ul li a:hover{   
    background-color: #DDDCDC;   
    display:block;   
  }   
  .menu2 ul{   
    list-style: none;   
  }   
  .menu2 ul li a{   
    float: left;   
    width: 14%;   
    display: block;   
    text-align: center;   
    color: #A4A4A4;   
    text-decoration: none;   
  }   
  .menu2 ul li a:hover{   
    background-color: #FAF9F9;   
    display:block;   
  }   
  .job p{   
    font-size: 12px;   
    margin: 0;   
    text-align:center;   
    margin: 10px;    
    color:#D9D8D8;   
  }   
  h3{   
    font-family: "Lucida Console";   
    font-weight: bold;   
    font-size: 24px;   
  }   
  p{   
    font-family: "Verdana";   
    font-size: 14px;   
    font-weight: lighter;   
    color: #ADACAC;   
  }   
  h1{   
    font-family: "Verdana";   
    font-size: 13px;   
    font-weight: bold;   
    text-align: center;   
    padding-top: 10px;   
  }   
  h2{   
    font-family: "Lucida Console";   
    font-weight: lighter;   
    font-size: 12px;   
  }  

Hasil:

Minggu, 23 September 2018

PBO A- REMOTE AC

Nama: Ayu Mutiara Sari
NRP: 05111740000149
Kelas:PBO A

Berikut ini adalah fungsi-fungsi yang ada di remote AC saya:
1. Fungsi untu menyala dan mematikan remote AC
2. Fungsi untuk mengatur suhu dan menampilkan suhu
3. Fungsi untuk mengatur mode AC dan menampilkan mode AC
4. Fungsi untuk mengatur fungsi swing AC

Saya menggunakan 2 class yaitu class main dan display:

Berikut Source codenya:

1. Main
 /**  
  * Write a description of class Main here.  
  * AC  
  * @author (ayu mutiara sari)  
  * @version (20.01)  
  */  
 import java.util.Scanner;    
  public class Main   
  {   
   public static void main(String args[])   
   {   
    {   
     Scanner scan= new Scanner(System.in);    
     int on, pilihan, mode, swing;   
     String mod;   
     System.out.println();   
     System.out.println("PANASONIC AIR CONDITIONER");   
     System.out.println("PRESS 0 TO TURN ON");   
     Display remote = new Display ();   
     on = scan.nextInt();   
     while(true){   
     if (on==0){   
      remote.print();   
     while (true){   
     pilihan = scan.nextInt();   
     switch (pilihan)   
     {   
     case 0:   
     System.out.println("TURNED OFF");   
     System.exit(0);   
     break;   
     case 1:   
     remote.TempUp();   
     remote.print();   
     break;   
     case 2:   
     remote.TempDown();   
     remote.print();   
     break;   
     case 3:   
     System.out.println("1. COOL");   
     System.out.println("2. HEAT");   
     System.out.println("3. AUTO");   
     System.out.println("4. DRY");   
     System.out.println("5. FAN");   
     mode=scan.nextInt();   
     if(mode<1 || mode>5){   
      System.out.println("ERROR.\n");   
      }   
     else{   
     mod= remote.getMode(mode);   
     }   
     remote.print();   
     break;   
     case 4:   
     remote.getSwing();   
     remote.print();   
     break;   
     }   
    }   
   }   
    else {   
    System.out.println("ERROR.");   
    on = scan.nextInt();   
     }   
    }   
   }   
  }   
  }   

2. Display
 /**  
  * Write a description of class display here.  
  *  
  * @author (ayu mutiara sari)  
  * @version (20.01)  
  */  
 public class Display   
  {   
   private int Temp;   
   private int nyala;   
   private int TempDef;   
   private int mode;   
   private String Mode, Swing;   
   private boolean isSwing;   
   /**   
   * Constructor for objects of class RemoteAC   
   */   
   public Display()   
   {   
    TempDef = 20;   
    Mode = new String("AUTO");   
    Swing = new String("OFF");   
    isSwing = false;   
   }   
   public int TempUp(){   
    if(TempDef==30){   
     System.out.println("--   INVALID   --");   
     System.out.println("-----------------------------------------");}   
     else{   
    TempDef++;}   
    return TempDef;   
   }   
   public int TempDown(){   
    if(TempDef==16){   
     System.out.println("--   INVALID   --");   
     System.out.println("-----------------------------------------");}   
     else{   
    TempDef--;}   
    return TempDef;   
   }   
   public String getMode(int mode){   
    if(mode==1){   
     Mode = new String ("COOL");   
    }   
    else if(mode==2){   
     Mode = new String ("HEAT");   
    }   
    else if(mode==3){   
     Mode = new String ("AUT)");   
    }   
    else if(mode==4){   
     Mode = new String ("DRY");   
    }   
    else if(mode ==5){   
     Mode = new String ("FAN");   
    }   
    else{   
     Mode = new String ("ERROR");   
  }   
   return Mode;}   
   public String getSwing(){   
    if (isSwing==false){   
     isSwing=true;   
     Swing=new String("ON");}   
    else {   
     isSwing=false;   
     Swing=new String("OFF");}   
     return Swing;   
    }   
   public void print(){   
    System.out.println("_____________________");   
    System.out.println("||  PANASONIC  ||");   
    System.out.println("|| AIR CONDITIONER ||");   
    System.out.println("||  "+TempDef+" CELCIUS  ||");   
    System.out.println("||  MODE = "+Mode+"  ||");   
    System.out.println("||  SWING = "+Swing+"  ||");   
    System.out.println("||-----------------||");   
    System.out.println("|| 1.Temperature ^ ||");   
    System.out.println("|| 2.Temperature v ||");   
    System.out.println("|| 3.Mode     ||");   
    System.out.println("|| 4.Swing Mode  ||");   
    System.out.println("|| 0.Turn Off   ||");   
    System.out.println("||-----------------||");   
    System.out.println("||_________________||");   
    System.out.println();   
  }   
  }   
Hasil:





Rabu, 19 September 2018

Belajar Menggunakan HTML dan CSS

Nama: Ayu Mutiara Sari
NRP: 05111740000149
Kelas: PWeb C

1. HTML Code
 <html> 
  <head> 
  <title>Belajar Membuat Layout dengan HTML dan CSS</title> 
  <link rel="stylesheet" href="custom.css"/> 
  </head> 
  <body> 
  <div class="header"> 
   <div class="jarak"> 
   <h2>Belajar Membuat Layout dengan HTML dan CSS</h2> 
   </div> 
  </div> 
  <div class="menu"> 
   <ul> 
   <li><a href="#">Home</a></li> 
   <li><a href="#">About</a></li> 
   <li><a href="#">Blog</a></li> 
   <li><a href="#">Contact</a></li> 
   </ul> 
  </div> 
  <div class="content"> 
   <div class="jarak"> 
   <!-- kiri --> 
   <div class="kiri"> 
    <!-- blog --> 
    <div class="border"> 
    <div class="jarak"> 
     <h3>Lorem Ipsum</h3> 
     <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
     tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim <button class="btn">Read More..</button> 
     </p> 
    </div> 
    </div> 
    <!-- end blog --> 
    <!-- blog --> 
    <div class="border"> 
    <div class="jarak"> 
     <h3>Lorem Ipsum</h3> 
     <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
     tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim <button class="btn">Read More..</button> 
    </p> 
    </div> 
    <!-- end blog --> 
   </div> 
  </div> 
   <!-- kiri --> 
   <!-- kanan --> 
   <div class="kanan"> 
    <div class="jarak"> 
    <h3>CATEGORY</h3> 
    <hr/> 
    <p><a href="#" class="undercor">HTML</a></p> 
    <p><a href="#" class="undercor">CSS</a></p> 
    <p><a href="#" class="undercor">BOOTSTRAP</a></p> 
    <p><a href="#" class="undercor">PHP</a></p> 
    <p><a href="#" class="undercor">MYSQL</a></p> 
    <p><a href="#" class="undercor">JQuery</a></p> 
    <p><a href="#" class="undercor">Ajax</a></p> 
    </div> 
   </div> 
   <!--kanan --> 
  </div> 
 </div> 
  <div class="footer"> 
   <div class="jarak"> 
   <p>Copyright 2018</p> 
   </div> 
  </div> 
  </div> 
 </body> 
 </html>


2. Code CSS

body{ 
  background: #f3f3f3; 
  color: #333; 
  width: 100% 
  font-family :sans-serif; 
  margin: 0 auto; 
 } 
 .header{ 
  width: 90%; 
  margin: auto; 
  height: 120px; 
  line-height: 120px; 
  background: #41A85F; 
  color: #fff; 
 } 
 .content{ 
  width: 90%; 
  margin: auto; 
  height: 420px; 
  padding: 0.1px; 
  background: #fff; 
  color: #333; 
 } 
 .kiri{ 
  width: 70%; 
  float: left; 
  margin: auto; 
  background: #fff; 
  height: 420px; 
 } 
 .kanan{ 
  width: 30%; 
  float: left; 
  margin: auto; 
  background: #fff; 
  height: 420px; 
 } 
 .border{ 
  border: 2px solid #74C599; 
  margin-top: 1pc; 
  padding-bottom: 1pc; 
  padding-left: 2pc; 
  padding-right: 2pc; 
 } 
 .undecor{ 
  text-decoration: none; 
 } 
 .footer{ 
  width: 90%; 
  margin: auto; 
  height: 40px; 
  line-height: 40px; 
  background: #41A85F; 
  color: #fff; 
 } 
 .menu{ 
  background-color: #53bd84; 
  height: 50px; 
  line-height: 50px; 
  position: relative; 
  width: 90%; 
  margin: 0 auto; 
  padding0 auto; 
 } 
 .jarak{ 
  padding: 0 2pc; 
 } 
 .menu ul{ 
  list-style: none; 
 } 
 .menu ul li a{ 
  float: left; 
  width: 70px; 
  display: block; 
  text-align: center; 
  color: #fff; 
  text-decoration: none; 
 } 
 .menu ul li a:hover{ 
  background-color: #74C599 
  display:block; 
 } 

Hasil:

Minggu, 16 September 2018

PBO A Menggambar Rumah

Nama: Ayu Mutiara Sari
Kelas: PBO A
NRP: 05111740000149

1. Kode Canvas

 import javax.swing.*;  
 import java.awt.*;  
 import java.util.List;  
 import java.util.*;  
 /**  
  * Write a description of class Picture here.  
  * Menggambar rumah  
  * @author (Ayu Mutiara Sari)  
  * @version (09.18)  
  */  
 public class Canvas  
 {  
   private static Canvas canvasSingleton;  
   public static Canvas getCanvas()  
   {  
     if(canvasSingleton == null) {  
       canvasSingleton = new Canvas("BlueJ Shapes Demo", 700, 500,   
                      Color.white);  
     }  
     canvasSingleton.setVisible(true);  
     return canvasSingleton;  
   }  
   private JFrame frame;  
   private CanvasPane canvas;  
   private Graphics2D graphic;  
   private Color backgroundColour;  
   private Image canvasImage;  
   private List objects;  
   private HashMap shapes;  
   private Canvas(String title, int width, int height, Color bgColour)  
   {  
     frame = new JFrame();  
     canvas = new CanvasPane();  
     frame.setContentPane(canvas);  
     frame.setTitle(title);  
     canvas.setPreferredSize(new Dimension(width, height));  
     backgroundColour = bgColour;  
     frame.pack();  
     objects = new ArrayList();  
     shapes = new HashMap();  
   }  
 public void setVisible(boolean visible)  
   {  
     if(graphic == null) {  
       Dimension size = canvas.getSize();  
       canvasImage = canvas.createImage(size.width, size.height);  
       graphic = (Graphics2D)canvasImage.getGraphics();  
       graphic.setColor(backgroundColour);  
       graphic.fillRect(0, 0, size.width, size.height);  
       graphic.setColor(Color.black);  
     }  
     frame.setVisible(visible);  
   }  
   public void draw(Object referenceObject, String color, Shape shape)  
   {  
     objects.remove(referenceObject);  // just in case it was already there  
     objects.add(referenceObject);   // add at the end  
     shapes.put(referenceObject, new ShapeDescription(shape, color));  
     redraw();  
   }  
   public void erase(Object referenceObject)  
   {  
     objects.remove(referenceObject);  // just in case it was already there  
     shapes.remove(referenceObject);  
     redraw();  
   }  
   public void setForegroundColor(String colorString)  
   {  
       if(colorString.equals("red"))  
       graphic.setColor(Color.red);  
     else if(colorString.equals("yellow"))  
       graphic.setColor(Color.yellow);  
     else if(colorString.equals("green"))  
       graphic.setColor(Color.green);  
     else if(colorString.equals("black"))  
       graphic.setColor(Color.black);  
     else if(colorString.equals("blue"))  
       graphic.setColor(Color.blue);  
     else if(colorString.equals("white"))  
       graphic.setColor(Color.white);  
     else  
       graphic.setColor(Color.black);  
   }  
   public void wait(int milliseconds)  
   {  
     try  
     {  
       Thread.sleep(milliseconds);  
     }   
     catch (Exception e)  
     {  
     }  
   }  
   private void redraw()  
   {  
     erase();  
     for(Iterator i=objects.iterator(); i.hasNext(); ) {  
       ((ShapeDescription)shapes.get(i.next())).draw(graphic);  
     }  
     canvas.repaint();  
   }  
   private void erase()  
   {  
     Color original = graphic.getColor();  
     graphic.setColor(backgroundColour);  
     Dimension size = canvas.getSize();  
     graphic.fill(new Rectangle(0, 0, size.width, size.height));  
     graphic.setColor(original);  
   }  
   private class CanvasPane extends JPanel  
   {  
     public void paint(Graphics g)  
     {  
       g.drawImage(canvasImage, 0, 0, null);  
     }  
   }  
   private class ShapeDescription  
   {  
     private Shape shape;  
     private String colorString;  
     public ShapeDescription(Shape shape, String color)  
     {  
       this.shape = shape;  
       colorString = color;  
     }  
     public void draw(Graphics2D graphic)  
     {  
       setForegroundColor(colorString);  
       graphic.fill(shape);  
     }  
   }  
 }  
2. Kode Circle

 /**  
  * Write a description of class Circle here.  
  * @author (Ayu Mutiara Sari)  
  * @version (09.18)  
  */  
  import java.awt.*;    
  import java.awt.geom.*;   
 public class Circle  
 {  
   private int diameter;  
   private int xPosition;  
   private int yPosition;  
   private String color;  
   private boolean isVisible;  
   public Circle()  
   {  
     diameter = 50;  
     xPosition = 20;  
     yPosition = 60;  
     color = "yellow";  
     isVisible = false;  
   }  
   public Circle(int x, int y){  
     diameter = 50;  
     xPosition = x;  
     yPosition = y;  
     color = "yellow";  
   }  
    public Circle(int x, int y, String col){  
     this(x,y,col,20);  
   }  
    public Circle(int x, int y, String col, int d){  
      diameter = d;  
     xPosition = x;  
     yPosition = y;  
     color = "blue";  
     makeVisible();  
   }  
   public void makeVisible()  
   {  
     isVisible = true;  
     draw();  
   }  
   public void makeInvisible()  
   {  
     erase();  
     isVisible = false;  
   }  
   public void moveRight()  
   {  
     moveHorizontal(20);  
   }  
   public void moveLeft()  
   {  
     moveHorizontal(-20);  
   }  
   public void moveUp()  
   {  
     moveVertical(-20);  
   }  
   public void moveDown()  
   {  
     moveVertical(20);  
   }  
   public void moveHorizontal(int distance)  
   {  
     erase();  
     xPosition += distance;  
     draw();  
   }  
   public void moveVertical(int distance)  
   {  
     erase();  
     yPosition += distance;  
     draw();  
   }  
   public void slowMoveHorizontal(int distance)  
   {  
     int delta;  
     if(distance < 0)   
     {  
       delta = -1;  
       distance = -distance;  
     }  
     else   
     {  
       delta = 1;  
     }  
     for(int i = 0; i < distance; i++)  
     {  
       xPosition += delta;  
       draw();  
     }  
   }  
   public void slowMoveVertical(int distance)  
   {  
     int delta;  
     if(distance < 0)   
     {  
       delta = -1;  
       distance = -distance;  
     }  
     else   
     {  
       delta = 1;  
     }  
     for(int i = 0; i < distance; i++)  
     {  
       yPosition += delta;  
       draw();  
     }  
   }  
   public void changeSize(int newDiameter)  
   {  
     erase();  
     diameter = newDiameter;  
     draw();  
   }  
   public void changeColor(String newColor)  
   {  
     color = newColor;  
     draw();  
   }  
   private void draw()  
   {  
     if(isVisible) {  
       Canvas canvas = Canvas.getCanvas();  
       canvas.draw(this, color, new Ellipse2D.Double(xPosition, yPosition,   
                              diameter, diameter));  
       canvas.wait(10);  
     }  
   }  
   private void erase()  
   {  
     if(isVisible) {  
       Canvas canvas = Canvas.getCanvas();  
       canvas.erase(this);  
     }  
   }  
 }  
3. Kode Square

 /**  
  * Write a description of class Square here.  
  *  
  * @author (ayu mutiara sari)  
  * @version (09.18)  
  */  
 import java.awt.*;  
 public class Square  
 {  
   private int size;  
      private int xPosition;  
      private int yPosition;  
      private String color;  
      private boolean isVisible;  
   public Square()  
   {  
           size = 30;  
           xPosition = 60;  
           yPosition = 50;  
           color = "red";  
           isVisible = false;  
   }  
      public void makeVisible()  
      {  
           isVisible = true;  
           draw();  
      }  
      public void makeInvisible()  
      {  
           erase();  
           isVisible = false;  
      }  
   public void moveRight()  
   {  
           moveHorizontal(20);  
   }  
   public void moveLeft()  
   {  
           moveHorizontal(-20);  
   }  
   public void moveUp()  
   {  
           moveVertical(-20);  
   }  
   public void moveDown()  
   {  
           moveVertical(20);  
   }  
   public void moveHorizontal(int distance)  
   {  
           erase();  
           xPosition += distance;  
           draw();  
   }  
   public void moveVertical(int distance)  
   {  
           erase();  
           yPosition += distance;  
           draw();  
   }  
   public void slowMoveHorizontal(int distance)  
   {  
           int delta;  
           if(distance < 0)   
           {  
                delta = -1;  
                distance = -distance;  
           }  
           else   
           {  
                delta = 1;  
           }  
           for(int i = 0; i < distance; i++)  
           {  
                xPosition += delta;  
                draw();  
           }  
   }  
   public void slowMoveVertical(int distance)  
   {  
           int delta;  
           if(distance < 0)   
           {  
                delta = -1;  
                distance = -distance;  
           }  
           else   
           {  
                delta = 1;  
           }  
           for(int i = 0; i < distance; i++)  
           {  
                yPosition += delta;  
                draw();  
           }  
   }  
   public void changeSize(int newSize)  
   {  
           erase();  
           size = newSize;  
           draw();  
   }  
   public void changeColor(String newColor)  
   {  
           color = newColor;  
           draw();  
   }  
      private void draw()  
      {  
           if(isVisible) {  
                Canvas canvas = Canvas.getCanvas();  
                canvas.draw(this, color,  
                               new Rectangle(xPosition, yPosition, size, size));  
                canvas.wait(10);  
           }  
      }  
      private void erase()  
      {  
           if(isVisible) {  
                Canvas canvas = Canvas.getCanvas();  
                canvas.erase(this);  
           }  
      }  
 }  
4. Kode Triangle

 /**  
  * Write a description of class Triangle here.  
  *  
  * @author (ayu mutiara sari)  
  * @version (09.18)  
  */  
 import java.awt.*;  
 public class Triangle  
 {  
   private int height;  
   private int width;  
      private int xPosition;  
      private int yPosition;  
      private String color;  
      private boolean isVisible;  
   public Triangle()  
   {  
           height = 30;  
           width = 40;  
           xPosition = 50;  
           yPosition = 15;  
           color = "green";  
           isVisible = false;  
   }  
      public void makeVisible()  
      {  
           isVisible = true;  
           draw();  
      }  
      public void makeInvisible()  
      {  
           erase();  
           isVisible = false;  
      }  
   public void moveRight()  
   {  
           moveHorizontal(20);  
   }  
   public void moveLeft()  
   {  
           moveHorizontal(-20);  
   }  
   public void moveUp()  
   {  
           moveVertical(-20);  
   }  
   public void moveDown()  
   {  
           moveVertical(20);  
   }  
   public void moveHorizontal(int distance)  
   {  
           erase();  
           xPosition += distance;  
           draw();  
   }  
   public void moveVertical(int distance)  
   {  
           erase();  
           yPosition += distance;  
           draw();  
   }  
   public void slowMoveHorizontal(int distance)  
   {  
           int delta;  
           if(distance < 0)   
           {  
                delta = -1;  
                distance = -distance;  
           }  
           else   
           {  
                delta = 1;  
           }  
           for(int i = 0; i < distance; i++)  
           {  
                xPosition += delta;  
                draw();  
           }  
   }  
   public void slowMoveVertical(int distance)  
   {  
           int delta;  
           if(distance < 0)   
           {  
                delta = -1;  
                distance = -distance;  
           }  
           else   
           {  
                delta = 1;  
           }  
           for(int i = 0; i < distance; i++)  
           {  
                yPosition += delta;  
                draw();  
           }  
   }  
   public void changeSize(int newHeight, int newWidth)  
   {  
           erase();  
           height = newHeight;  
           width = newWidth;  
           draw();  
   }  
   public void changeColor(String newColor)  
   {  
           color = newColor;  
           draw();  
   }  
      private void draw()  
      {  
           if(isVisible) {  
                Canvas canvas = Canvas.getCanvas();  
                int[] xpoints = { xPosition, xPosition + (width/2), xPosition - (width/2) };  
                int[] ypoints = { yPosition, yPosition + height, yPosition + height };  
                canvas.draw(this, color, new Polygon(xpoints, ypoints, 3));  
                canvas.wait(10);  
           }  
      }  
      private void erase()  
      {  
           if(isVisible) {  
                Canvas canvas = Canvas.getCanvas();  
                canvas.erase(this);  
           }  
      }  
 }  

Senin, 10 September 2018

PBOA 2- 10 September 2018

TUGAS 2 - Pemrograman Berbasis Objek
Membuat Program Menghitung luas dan keliling bangun ruang dengan menggunakan class dan Object dengan program BlueJ.
Nama : Ayu Mutiara Sari
NRP : 05111740000149
Kelas : PBO A


1. Source Code Main
/** * Write a description of class Main here. * * Ayu Mutiara Sari * 10.09.2018 */ public class Main { public static void main() { Persegi apersegi; apersegi =new Persegi(); apersegi.sisi= 6; double luasAP=apersegi.luas(); double kellAP=apersegi.kell(); System.out.println("Luas dan Keliling Persegi"); System.out.println("Sisi="+apersegi.sisi+"Luas="+luasAP); System.out.println("Sisi="+apersegi.sisi+"Keliling="+kellAP+"\n"); BelahKetupat BBk; BBk =new BelahKetupat(); BBk.sisi=10; BBk.d1=11; BBk.d2=13; double luasBK=BBk.luas(); double kellBK=BBk.kell(); System.out.println("Luas dan Keliling Belah Ketupat"); System.out.println("Sisi="+BBk.sisi+"D1="+BBk.d1+"D2="+BBk.d2+"Luas="+luasAP); System.out.println("Sisi="+BBk.sisi+"D1="+BBk.d1+"D2="+BBk.d2+"Keliling="+kellAP+"\n"); JajaranGenjang JG; JG=new JajaranGenjang(); JG.alas=12; JG.tinggi=5; JG.sisimiring=8; double luasJG=JG.luas(); double kellJG=JG.kell(); System.out.println("Luas dan Keliling Jajaran Genjang"); System.out.println("Alas="+JG.alas+" Tinggi="+JG.tinggi+" Sisi Miring"+JG.sisimiring+" Luas="+luasJG); System.out.println("Alas="+JG.alas+" Tinggi="+JG.tinggi+" Sisi Miring"+JG.sisimiring+" Keliling="+kellJG+"\n"); PersegiPanjang PP; PP=new PersegiPanjang(); PP.panjang=10; PP.lebar=6; double luasPP=PP.luas(); double kellPP=PP.kell(); System.out.println("Luas dan Keliling Persegi Panjang"); System.out.println("Panjang="+PP.panjang+" Lebar="+PP.lebar+" Luas="+luasPP); System.out.println("Panjang="+PP.panjang+" Lebar="+PP.lebar+" Keliling="+kellPP+"\n"); Segitiga SG; SG=new Segitiga(); SG.alas=12; SG.tinggi=7; double luasSG=SG.luas(); double kellSG=SG.kell(); System.out.println("Luas dan Keliling Segitiga"); System.out.println("Alas="+SG.alas+" Tinggi="+SG.tinggi+" Luas="+luasSG); System.out.println("Alas="+SG.alas+" Keliling="+kellSG+"\n"); } }

2. Source Code Persegi
 /**  
  * Write a description of class Persegi here.  
  * Menghitung Luas dan Keliling Persegi  
  * @author (Ayu Mutiara Sari)  
  * @version (10.09.2018)  
  */  
 public class Persegi  
 {  
   public double sisi;   
   public double luas()   
   {   
    return sisi*sisi;   
   }   
   public double kell()   
   {   
    return 4*sisi;   
   }   
 }  

3. Source code Belah ketupat
 /**  
  * Write a description of class BelahKetupat here.  
  * Menghitung luas dan keliling Belah ketupat  
  * @author (Ayu Mutiara Sari)  
  * @version (10.09.2018)  
  */  
 public class BelahKetupat   
  {   
   public double d1,d2,sisi;   
   public double luas()   
   {   
    return (d1*d2)/2;   
   }   
   public double kell()   
   {   
    return 4*sisi;   
   }   
  }   

4. Source Code Jajaran Genjang
 /**  
  * Write a description of class JajaranGenjang here.  
  * Menghitung Luas dan keliling jajaran genjang   
  * @author (Ayu Mutiara Sari)  
  * @version (10.09.2018)  
  */  
  public class JajaranGenjang   
  {   
   public double alas,tinggi,sisimiring;   
   public double luas()   
   {   
    return alas*tinggi;   
   }   
   public double kell()   
   {   
    return 2*(alas+sisimiring);   
   }   
  }   

5. Source Code Persegi Panjang
 /**  
  * Write a description of class PersegiPanjang here.  
  * Menghitung Luas dan Keliling Persegi Panjang  
  * @author (Ayu Mutiara Sari)  
  * @version (10.09.2018)  
  */  
 public class PersegiPanjang   
  {   
   public double panjang,lebar;   
   public double luas()   
   {   
    return panjang*lebar;   
   }   
   public double kell()   
   {   
    return 2*(panjang+lebar);   
   }   
  }   

6. Source Code Segitiga
 /**  
  * Write a description of class Segitiga here.  
  * Menghitung Luas dan Keliling Segitiga  
  * @author (Ayu Mutiara Sari)  
  * @version (10.09.2018)  
  */  
 public class Segitiga   
  {   
   public double alas,tinggi;   
   public double luas()   
   {   
    return (alas*tinggi)/2;   
   }   
   public double kell()   
   {   
    return 3*alas;   
   }   
  }   

Hasil run:

Selasa, 04 September 2018

Tugas Pweb 1 Kelas C

 <HTML>   
 <HEAD>   
 <TITLE>My Personal Info</TITLE>   
 </HEAD>  
 <BODY background="dinding.png">  
 <h1 style="background-color:MistyRose;text-align:center;font-size:42pt;"><i><span style="background-color:MistyRose;color:BurlyWood;">Curriculum Vitae</i></h1>  
 <!-- header start -->  
 <div style="position:absolute;top:130px;left:450px;background-color:MistyRose;">  
 <img src="C:\Users\Ayu's PC\Pictures\ayu-cv.jpg" alt="Dp" style="width:145px;height:178px;">   
 </div>  
 <div style="position:absolute;top:140px;left:900px;background-color:MistyRose;color:BurlyWood;">  
 <h2 >Ayu Mutiara Sari<br>Griya Kebraon Barat 14/ CG-13 Surabaya <br>081289345364<br>ayumutiara98@gmail.com</h2>  
 </div>  
 <!-- header end -->  
 <div style="position:absolute;top:400;left:60px;background-color:MistyRose;color:BurlyWood;">  
 <pre><h1 style="font-size:25pt;">About Me:</h1>  
 <p> My name is Ayu Mutiara Sari, I am the third born in my family. I was born in Surabaya, 3 July 1998. <br> I am studying Informatics at Institut Teknologi Sepuluh Nopember Surabaya. I like to learn new things. <br> I also have high motivation to explore and take chances so I can enhance my knowledge and skills.  
 </p>  
 </div>  
 <hr>  
 <div style="position:absolute;top:700px;left:100px;background-color:MistyRose;color:BurlyWood">  
 <h1 style="font-size:25pt;">Formal Education:</h1>  
    <table style="color:BurlyWood;">  
 <tr>  
   <th>Institution</th>  
   <th>Year</th>  
 </tr>  
 <tr>  
   <td>SDN Kebraon II Surabaya </td>  
   <td>2004-2010</td>  
 </tr>  
 <tr>  
   <td>SMP Negeri 16 Surabaya</td>  
   <td>2010-2013</td>  
 </tr>  
 <tr>  
   <td>SMA Negeri 1 Surabaya</td>  
   <td>2013-2016</td>  
 </tr>  
 <tr>  
   <td>Intitut Teknologi Sepuluh Nopember</td>  
      <td>2017-Present</td>  
 </tr>  
 </table>  
 <br>  
 </div>  
 <div style="position:absolute;top:700px;left:700px;background-color:MistyRose;color:BurlyWood">  
 <h1 style="font-size:25pt;">Informal Education:</h1>  
    <table style="color:BurlyWood;">  
 <tr>  
      <th>Qualification<</th>  
   <th>Institution</th>  
   <th>Year</th>  
 </tr>  
 <tr>  
   <td>General English</td>  
      <td>Surabaya Training Center (STC)</td>  
   <td>2004-2010</td>  
 </tr>  
 <tr>  
   <td>General English</td>  
      <td>The British Institute</td>  
   <td>2015-2016</td>  
 </tr>  
 <tr>  
   <td>Basic Adobe</td>  
      <td>KIV(World Friend IT) </td>  
   <td>2016</td>  
 </tr>  
 <tr>  
   <td>Graphic Design and Illustration(Adobe Illustration CS6)</td>  
      <td>Adobe Certified Associate </td>  
   <td>2017</td>  
 </tr>  
 </table>  
 <br>  
 </div>  
 <div style="position:absolute;top:400px;left:1000px;background-color:MistyRose;color:BurlyWood">  
                <h1><span>My Hobbies</span></h1>  
                <ul>  
                     <li>Cooking <br />  
                          <progress min="0" max="100" value="40"></progress>  
                     </li>  
                     <li>Reading <br />  
                          <progress min="0" max="100" value="70"></progress>  
                     </li>  
                     <li>Singing <br />  
                          <progress min="0" max="100" value="50"></progress>  
                     </li>  
                     <li>Travelling <br />  
                          <progress min="0" max="100" value="90"></progress>  
                     </li>  
                     <li>Watching Movies <br />  
                          <progress min="0" max="100" value="90"></progress>  
                     </li>  
                </ul>  
           </div>  
 </BODY>   
 </HTML>   

Minggu, 02 September 2018

Tugas PBO A 1- 3 September 2018

Tugas PBO 1 ini menggunakan Bahasa pemrograman Java dengan IDE BlueJ. Saya menuliskan data diri Saya seperti gambar berikut (hasil compile BlueJ) :
Berikut Source Code nya:

 /**  
  * Write a description of class Biodata here.  
  * Tugas PBOA 1 untuk menuliskan data diri  
  * @author Ayu Mutiara Sari  
  * @version 01/20180903  
  */  
 public class Biodata  
 {  
   // instance variables - replace the example below with your own  
   private int x;  
   /**  
    * Constructor for objects of class Biodata  
    */  
   public Biodata()  
   {  
     // initialise instance variables  
     x = 0;  
     System.out.println("Nama     : Ayu Mutiara Sari");  
     System.out.println("Kelas    : PBO A");  
     System.out.println("Alamat Rumah : Griya Kebraon Barat 14/CG-13 Surabaya.");  
     System.out.println("Email    : ayumutiara98@gmail.com");  
     System.out.println("Blog     : ayumtrsr.blogspot.com");  
     System.out.println("No. HP/WA  : 081289345364");  
     System.out.println("Twitter   : @ayu_mutiarasari");  
   }  
   /**  
    * An example of a method - replace this comment with your own  
    *  
    * @param y a sample parameter for a method  
    * @return  the sum of x and y  
    */  
   public int sampleMethod(int y)  
   {  
     // put your code here  
     return x + y;  
   }  
 }