Help with this easy Java pgm
Could someone pls pop in the codes in the comments below. Ive tried a lot but i always get these crazy errors while compiling ,which i can t figure out .
Thanx a ton !!!
import java.util.*;
import abc.*;
public class MessageSkeleton{
// instance variables
private String toAddress;
private String fromAddress;
private String subject;
private String[] messageBody;
private int messageLines;
private int maxLines;
private String recievedDate;
private String sentDate;
// constructor - builds a blank message
public MessageSkeleton(int max)
{
// set sentDate and recievedDate to be null
sentDate = "null";
recievedDate = "null";
// set toAddress, fromAddress, and subject to be null
toAddress = "null";
fromAddress = "null";
// set messageLines to be 0
messageLines = 0;
// set maxLines to be the parameter passed to constructor
maxLines = max;
// set messageBody array to have maxLines elements
messageBody = new String[maxLines];
}
// compose method that allows the user to enter data into the email message
public void compose(String myAddress)
{
// declare some variables that will be used in the constructor
int lineCounter;
boolean moreInput = true;
String inputString;
// create new Easy Reader object to read data from keyboard
EasyReader keyboard = new EasyReader();
System.out.println("New message is from " + myAddress);
fromAddress = myAddress;
// get recipient email address
System.out.print("Please enter recipient address ");
toAddress = getAddress( keyboard );
// get subject
// add your own code here to read the message subject from the keyboard
// get mail body text
System.out.println("Please enter the email text, line by line");
System.out.println("You can enter a maximum of " + maxLines + " lines of text, enter '.' to finish");
lineCounter = 0;
while (moreInput == true)
{
// add your own code here to read the message body from the keyboard
}
}
// print method
public void printToScreen()
{
int lineCounter;
String dashLine = "--";
System.out.println(dashLine);
System.out.println("To:" + toAddress);
System.out.println("From:" + fromAddress);
System.out.println("\n" + dashLine);
System.out.println("Sent:" + sentDate);
System.out.println("Recieved: " + recievedDate);
System.out.println("\n" + dashLine );
System.out.println("Subject: " + subject);
System.out.println("\n" + dashLine + "\n");
for (lineCounter = 0; lineCounter <= messageLines-1; lineCounter++)
{
System.out.println(lineCounter+1 + " " + messageBody[lineCounter]);
}
}
// edit method
// each part of the message is edited in turn
public void edit()
{
EasyReader keyboard = new EasyReader();
String response;
// edit recipient
String newRecipient;
System.out.println("Edit recipient");
System.out.println("Recipient is currently "+getToAddress());
System.out.print("Change (Y/N)?");
response = getKeyboardChar( keyboard );
if (response.equals("y"))
{
newRecipient = getAddress( keyboard );
setToAddress(newRecipient);
}
// edit subject
// add your own code here allow the user to edit the subject
// edit body
String newLine;
System.out.println("Edit message body, one line at a time");
// add your own code here allow the user to edit the message body
}
private String getKeyboardChar(EasyReader keyboard)
{
String response;
response = keyboard.readString();
response = response.toLowerCase();
response = response.substring(0,1);
return response;
}
private String getAddress( EasyReader keyboard )
{
String address = keyboard.readString();;
boolean formatOK = false;
while (formatOK == false)
{
// check it is a valid email addressxxxx@yyyy
if (address.indexOf('@') == -1)
{
System.out.print("Email address should contain @, please try again ");
address = keyboard.readString();
}
else
{
formatOK = true;
}
}
return address;
}
// get methods
public String getSubject()
{
return subject;
}
public String getToAddress()
{
return toAddress;
}
public String getFromAddress()
{
return fromAddress;
}
public String[] getMessageBody()
{
return messageBody;
}
public String getSentDate()
{
return sentDate;
}
public String getRecievedDate()
{
return recievedDate;
}
public int getMessageLines()
{
return messageLines;
}
// set methods
public void setSubject( String newSubject )
{
subject = newSubject;
}
public void setToAddress( String newAddress )
{
toAddress = newAddress;
}
public void setFromAddress(String newAddress )
{
fromAddress = newAddress;
}
public void setMessageLines( int newMessageLines )
{
messageLines = newMessageLines;
}
public int setMessageBodyLine(String newLine, int lineNumber)
{
if ((lineNumber > messageLines)||(lineNumber < 0))
{
return 0; // error
}
else
{
messageBody[lineNumber] = newLine;
return 1; // success
}
}
public void setRecievedDate(String newDate)
{
recievedDate = newDate;
}
public void setSentDate(String newDate)
{
sentDate = newDate;
}
}

