john2054

Robot

Sep 21st, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1. public class Robot {
  2.  
  3.   String name;
  4.  
  5.   Robot (String name) {
  6.     this.name = name;
  7.   }
  8.  
  9.   void speak (String msg) {
  10.     System.out.println(msg + name);
  11.   }
  12.  
  13.   public static void main (String[] args) {
  14.    
  15.    Robot r = new Robot("debbie");
  16.    
  17.     r.speak("hey there! It's me... ");
  18.    
  19.     Robot b = new Robot("bob");
  20.     b.speak("My name is... ");
  21.   }
  22.  
  23. }
Add Comment
Please, Sign In to add comment