} // Chuyen noi dung XML thanh Nghiem public static Nghiem XMLtoNghiem(String xmlDoc) { Nghiem kq; XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlDoc); XmlElement root = doc.DocumentElement; switch (root.Name) { case "NGHIEMBAC2": kq = new NghiemBac2(); break; case "NGHIEMBAC1": kq = new NghiemBac1(); break; default: kq = null; break; } kq.GetXMLDocument(xmlDoc); return(kq); }
public override Nghiem GiaiPT() { Nghiem kq; if (A == 0) { NhiThuc nt = new NhiThuc(B, C); kq = nt.GiaiPT(); } else { kq = new NghiemBac2(); float delta = m_B * m_B - 4 * m_A * m_C; if (delta > 0) { float temp = (float)Math.Sqrt((double)delta); kq.Add((-m_B + temp) / (2 * m_A)); kq.Add((-m_B - temp) / (2 * m_A)); } else if (delta == 0) { kq.Add(-m_B / (2 * m_A)); } } return(kq); }