Question: LAB 2 : Instructions Implement these changes / additions over the last assignment ( Lab # 1 ) . You may work your own

LAB 2: Instructions
Implement these changes / additions over the last assignment (Lab \#1). You may work your own solution to Lab \#1, or use the one posted on Blackboard (check the corresponding assignment link to find the solution).
The details of the methods are (mostly) not provided. It is up to you to find a suitable implementation. A solution will be provided afterwards, so you may continue from the solution file for future labs \& assignments.
Zip your entire project folder and upload the .zip file to Blackboard. Have fun!!! user class; using System;
using System.Collections.Generic;
using System.Text;
namespace LAB1
{
class User
{
private String Name { get; set; }
private String EmailAddress { get; set; }
private Mailbox Inbox { get; set; }
private Mailbox Outbox { get; set; }
public User(String name, String emailAddress)
{
Name = name; EmailAddress = emailAddress;
Inbox = new Mailbox(); Outbox = new Mailbox();
}
public void ComposeMail(User otherUser)
{
Console.WriteLine(Name +""+ EmailAddress +"> composing a mail to: "+ otherUser.Name +""+ otherUser.EmailAddress +">...");
Console.WriteLine("Enter subject:");
String subject = Console.ReadLine();
Console.WriteLine("Enter body:");
String body = Console.ReadLine();
(String, String) sender =(Name, EmailAddress);
(String, String) receiver =(otherUser.Name, otherUser.EmailAddress);
Mail composedMail = new Mail(DateTime.Now, sender, receiver, subject, body);
if(Outbox.Mails.Count >= Outbox.Capacity || otherUser.Inbox.Mails.Count >= otherUser.Inbox.Capacity)
{
Console.WriteLine("Capacity exceeded!");
Console.WriteLine();
return;
}
Outbox.Mails.Add(composedMail);
otherUser.Inbox.Mails.Add(composedMail);
Console.WriteLine("Mail successfully sent.");
Console.WriteLine();
}
public void ReadInbox()
{
Console.WriteLine("Inbox for "+ Name +""+ EmailAddress +">:");
Inbox.DisplayMailbox();
if(Inbox.Mails.Count >0)
{
Console.Write("
Enter the number for the mail you want to read: ");
int selection = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
Inbox.ReadMail(selection -1);
}
Console.WriteLine();
}
public void ReadOutbox()
{
Console.WriteLine("Outbox for "+ Name +""+ EmailAddress +">:");
Outbox.DisplayMailbox();
if (Outbox.Mails.Count >0)
{
Console.Write("
Enter the number for the mail you want to read: ");
int selection = Convert.ToInt32(Console.ReadLine());
Outbox.ReadMail(selection -1);
}
Console.WriteLine();
}
}
} mail class ;using System;
using System.Collections.Generic;
using System.Text;
namespace LAB1
{
class Mail
{
private DateTime Date;
private String Subject;
private String Body;
public (String, String) Sender { get; private set; }
public (String, String) Receiver { get; private set; }
public DateTime GetDate(){ return Date; }
public String GetSubject(){ return Subject; }
public String GetBody(){ return Body; }
public Mail(DateTime date, (String, String) sender,(String, String) receiver, String subject, String body)
{
Date = date; Sender = sender; Receiver = receiver; Subject = subject; Body = body;
}
public override String ToString()
{
String finalString = Date.ToShortDateString()+","+ Date.ToShortTimeString()+"
";
finalString += "From: "+ Sender.Item1+""+ Sender.Item2+">
";
finalString +="To: "+ Receiver.Item1+""+ Receiver.Item2+">
";
finalString += "Subject: "+ Subject +"
"+ Body;
return finalString;
}
public void DisplayHeader(){ Console.WriteLine("Subject: "+ Subject); }
}
}mailbox class;using System;
using System.Collections.Generic;
using System.Text;
namespace LAB1
{
class Mailbox
{
public List Mails { get; set; }
public int Capacity { get; set; }
public Mailbox()
{
Mails = new List();
Capacity =1; // To test capacity
}
public void DisplayMailbox()
{
if (Mails.Count ==0)
Console.WriteLine("No mails here!");
else {
for(int i =0; i Mails.Count; i++){
Console.Write((i+1)+")");
Mails[i].DisplayHeader();
}
}
}
public void ReadMail(int selection)
{
Console.WriteLine(Mails[selection].ToString());
}
}
} program cs ;using System;
namespace LAB1
{
class Program
{
static void Main(string[] args)
{
User cg = new User("Cinar Gedizlioglu", "c.gedizlioglu");
User ke = new User("Kutluhan Erol", "k.erol");
ke.ComposeMail(cg);
cg.ComposeMail(ke);
ke.ReadInbox();
ke.ReadOutbox();
// Capacity exceeded here
cg.ComposeMail(ke);
ke.ReadInbox();
}
}
}
LAB 2 : Instructions Implement these changes /

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!