• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Introducing an object  RSS feed

 
daniel kidanee
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am new to java oop. The following is my first program and can any one help me what
I am missing that I couldn't get the task right? Thank you in advance!
Task:The main method of the class Things below creates an object called printer deriving from the class PrintingClass and uses that object to print text. Your task is to write the PrintingClass class.

Program to complete:


Note: In this exercise the solution is part of a conversion unit where many classes have been declared. Because of this the classes are not declared as public using the public attribute.
Example output


Type in the character string for printing: John Doe
John Doe

My Class:


 
Paweł Baczyński
Bartender
Posts: 2082
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shouldn't you method take an argument?
 
Rico Felix
Ranch Hand
Posts: 411
5
IntelliJ IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By observing your code in both classes, firstly the PrintingClass class does not contain a Print(String) method so the invocation of such method on a PrintingClass reference will not be valid (pay attention to capitalization and argument passing(valid number and types of arguments)). Secondly as Pawel Pawlowicz pointed out what you are trying to do is delagate a task to the System.out.print() passing in the string that the user typed, but your method print() in the PrintingClass class does not accept the string to do the delegation properly so there is the flaw in your code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!