Need some assistance
- From: aver24@xxxxxxxxxxx
- Date: 10 Dec 2005 10:03:39 -0800
This is the error I get:
1 error found:
File: C:\JBuilder3\myprojects\PostCardDemo.java [line: 9]
Error: cannot resolve symbol
symbol : constructor PostCard (java.lang.String)
location: class PostCard
My teacher told me I didn't create the class, but I thought I did
'class PostCard'. Do I have to create an additional class? The last
lines of the program are commented out, but I assume that if I fix the
other errors that one will work too.
public class PostCardDemo {
public static void main(String[] args) {
String text = "\tI'm having a wonderful\n" +
"time at Disney World. Weather's\n" +
"great. Wish you were here!";
PostCard p1 = new PostCard("Vanna", text);
PostCard p2 = new PostCard(text);
p2.setRecipient("Merv");
System.out.println(p2.print());
System.out.println(p1.print());
p2.setRecipient("Mom");
p2.print();
PostCard p3 = new PostCard("Sweetie",
"\tI'm miserable without\n" +
"you. It's been raining all week.\n" +
"I can't wait to get back home.");
p3.print();
}
}
class PostCard {
public String recipient;
public String content;
public PostCard(String r, String t) {
recipient = r;
content = t;
content = recipient + content;
}
public String print(){
return content;
}
public String setRecipient(String n){
recipient = n;
return recipient;
}
}
//public String toString(){
//return PostCard("[Dear " + recipient +"]");
//}
.
- Follow-Ups:
- Re: Need some assistance
- From: Rhino
- Re: Need some assistance
- From: pit . grinja
- Re: Need some assistance
- Prev by Date: Re: How to avoid the message "Unknown source"?
- Next by Date: Re: How to avoid the message "Unknown source"?
- Previous by thread: How to avoid the message "Unknown source"?
- Next by thread: Re: Need some assistance
- Index(es):