using System; using System.Collections.Generic; using System.Web; public class C
ID: 3538555 • Letter: U
Question
using System;
using System.Collections.Generic;
using System.Web;
public class Chat
{
private Guid m_id;
public Guid Id
{
get { return m_id; }
}
private List<string> m_messages = new List<string>();
public List<string> Messages
{
}
private List<Chatter> m_chatters = new List<Chatter>();
public List<Chatter> Chatters
{
get { return m_chatters; }
set { m_chatters = value; }
}
public static ReadOnlyCollection<Chat>
{
if (HttpContext.Current.Application["Chats"] != null)
{
List<Chat> chats = ((List<Chat>)HttpContext.Current.Application["Chats"]);
return new ReadOnlyCollection<Chat>(chats);
}
else
{
return new ReadOnlyCollection<Chat>(new List<Chat>());
}
}
public string SendMessage(Chatter chatter, string message)
{
string messageMask = "{0} @ {1} : {2}";
message = string.Format(messageMask, chatter.Name, DateTime.Now.ToString(), message);
m_messages.Add(message);
return message;
}
public Chat()
{
m_id = Guid.NewGuid();
}
}
Explanation / Answer
The errors are as below per line:
3rd : using System.Collections.ObjectModel;
14th: get { return m_id; }
32th: ActiveChats()
and complete program is:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Web;
public class Chat
{
private Guid m_id;
public Guid Id
{
get { return m_id; }
}
private List<string> m_messages = new List<string>();
public List<string> Messages
{
get { return m_messages; }
}
private List<Chatter> m_chatters = new List<Chatter>();
public List<Chatter> Chatters
{
get { return m_chatters; }
set { m_chatters = value; }
}
public static ReadOnlyCollection<Chat> ActiveChats()
{
if (HttpContext.Current.Application["Chats"] != null)
{
List<Chat> chats = ((List<Chat>)HttpContext.Current.Application["Chats"]);
return new ReadOnlyCollection<Chat>(chats);
}
else
{
return new ReadOnlyCollection<Chat>(new List<Chat>());
}
}
public string SendMessage(Chatter chatter, string message)
{
string messageMask = "{0} @ {1} : {2}";
message = string.Format(messageMask, chatter.Name, DateTime.Now.ToString(), message);
m_messages.Add(message);
return message;
}
public Chat()
{
m_id = Guid.NewGuid();
}
}
Hope you will get ur answer and rate me. Thanks
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.