Hey im stuck on this question could anyone please help The q

Hey, im stuck on this question, could anyone please help. The question must be solved using the given instructions

Design a class Message that models an email message. A message has a sender, a recipient, a message text, and a tag line. The following methods should be included: • A constructor that takes the sender and recipient as parameters • A method setTagLine that sets the tag line, that when printed appears at the foot of the email message • A method toString that makes the message into one long string, for example: \"From: Harry Morgan\ To: Rudolf Reindeer\ ... \" • A method print that prints the message followed by the tag line. You will need to write a test class to ensure that your Message class functions correctly. An example run, with the different parts as follows: Line 1 4 Sender Line 2 - Recipient Lines 4 to 8 + Message text Line 10 + Tag line 1 From: Harry Morgan 2 To: Barry Wiles 4 Dear so and so, 5 It is Iny great pleasure to 6 write you an email. 8 Goodbye! 10 - - - - - Fun in CP1 - - - - - -

Solution

/* Program code begins */

class email
{
String sender,receiver;
String footer=\"--------------------------Footer Message--------------------\";
String body=\"Dear so and so\ \"
       +\"it is graet pleasure to\ \"
       +\"write your email.\";
      
email(String s,String r)                               //Constructor with sender,receiver parameters
{
           sender=s;
           receiver=r;
           //System.out.println(sender+\" \"+receiver);
  
}

public static void main(String args[])                   //main function ,execution starts from here
{
   email b=new email(\"Ashok\",\"Kumar\");                   //creating class object,calling constructor
       b.printdata();                                       //print function to display email msg
     
}

  
public void setTagLine(String foo)                       //function to set footer,just call this function where to display footer msg
{
System.out.println(\"\ \"+foo);
       //return foo;
}
   public void toStr()                                   //toString function set all email msg to as string varible msg
{
       String msg=\"\";
       msg=\"From : \"+sender+\"\ \"+
       \"To : \"+receiver+\"\ \ \"+
       body+\"\ \";

System.out.println(msg);
                                          
  
}
   public void printdata()                               //print function to display email msg
   {
       toStr();
       setTagLine(footer);
   }
}

INPUT : By default input given to this program in varibles like sender,reciver,body,footer. You can read also from standard input.

OUTPUT : java email

From : Ashok
To : Kumar

Dear so and so
it is graet pleasure to
write your email.


--------------------------Footer Message--------------------

Hey, im stuck on this question, could anyone please help. The question must be solved using the given instructions Design a class Message that models an email m
Hey, im stuck on this question, could anyone please help. The question must be solved using the given instructions Design a class Message that models an email m

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site