Guest User

Untitled

a guest
Jul 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. /*
  2. *
  3. */
  4.  
  5. public class SongApp{
  6. public static void main(String[] args){
  7. Song song1 = new Song();
  8. song1.setsongLine("While my guitar gently weeps.");
  9. song1.display();
  10. song1.process();
  11. Song song2 = new Song();
  12. song2.setsongLine("Let it be");
  13. song2.display();
  14. }
  15. }
  16.  
  17. /*
  18. *
  19. */
  20.  
  21. public class Song{
  22. // data field declaration
  23. private String songLine;
  24.  
  25.  
  26. /*sets the value of the data field songLine to input parameter value*/
  27. public void setsongLine(String songLine){
  28. this.songLine = songLine;
  29. } //end method
  30.  
  31. /*returns the value of the data field songLine */
  32. public String getsongLine(){
  33. return songLine;
  34. } //end method
  35.  
  36.  
  37. //method called process
  38. public String process(){
  39. int stringLength = songLine.length();
  40. }
  41. /*displays formatted songLine information to the console window */
  42. public void display(){
  43. System.out.println(songLine);
  44. System.out.println("Length is :" + process());
  45. }
  46. }
  47.  
  48. public static void main(String[] args){
  49. ...
  50. System.out.println(song1.process());
  51. ...
  52. }
  53. public String process(){
  54. return "Length is " + songLine.length();
  55. }
  56.  
  57. public void process(){
  58. System.out.println("Length is " + songLine.length());
  59. }
  60.  
  61. public Integer process() {
  62. return songLine.length();
  63. }
Add Comment
Please, Sign In to add comment