Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1.  
  2. public class Wyraz {
  3.  
  4. String str;
  5. int x;
  6.  
  7. public Wyraz(){
  8. this.str="";
  9. this.x=0;
  10.  
  11. }
  12.  
  13. public void dodajZnak(char letter){
  14. str+=letter;
  15. x++;
  16. }
  17.  
  18. public String toString(){
  19. return str;
  20. }
  21.  
  22. public int length(){
  23. return x;
  24. }
  25.  
  26. public static void main(String[] args) {
  27. Wyraz wy= new Wyraz();
  28. wy.dodajZnak('a');
  29. System.out.println(wy.toString());
  30. System.out.println(wy.length());
  31. wy.dodajZnak('b');
  32. System.out.println(wy.toString());
  33. System.out.println(wy.length());
  34. // TODO Auto-generated method stub
  35.  
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement