Last active
August 29, 2015 14:05
-
-
Save lb7n/5b13b6db7efb9baee9be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Mainclass { | |
public static void main (String [] args) | |
{ | |
String name = "Star Wars Robot Machine"; | |
String serialNumber = " 6000"; | |
RobotPrinter poop = new RobotPrinter (name, serialNumber); | |
poop.addString("May the force be with you"); | |
poop.addString("Hokey religions and ancient weapons are no match for a good blaster at your side, kid."); | |
poop.addString("Who's the more foolish, the fool or the fool who follows him?"); | |
poop.addString("I felt a great disturbance in the Force, as if millions of voices suddenly cried out in terror and were suddenly silenced. I fear something terrible has happened."); | |
poop.addString("The Force is strong with this one."); | |
poop.printArrayList(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Robot Printer | |
import java.util.ArrayList; | |
public class RobotPrinter { | |
private String name; | |
private String serialNumber; | |
private ArrayList <String> words; | |
public RobotPrinter(String name, String serialNumber){ | |
this.name = name; | |
this.serialNumber = serialNumber; | |
this.words = new ArrayList <String> (); | |
System.out.println("Robot " + name + " activated. Serial number: " + serialNumber); | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String getSerialNumber() { | |
return serialNumber; | |
} | |
public void setSerialNumber(String serialNumber) { | |
this.serialNumber = serialNumber; | |
} | |
public ArrayList<String> getWords() { | |
return words; | |
} | |
public void setWords(ArrayList<String> words) { | |
this.words = words; | |
} | |
public void addString(String weedStrains){ | |
words.add(weedStrains); | |
} | |
public void printArrayList(){ | |
for (int i = 0; i<words.size(); i++){ | |
System.out.println(words.get(i)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment