static void Main(String[] args) { string title = Console.ReadLine(); string author = Console.ReadLine(); int price = int.Parse(Console.ReadLine()); Book new_novel = new MyBook(title, author, price); new_novel.display(); }
static void Main(String[] args) { String title = Console.ReadLine(); String author = Console.ReadLine(); int price = Int32.Parse(Console.ReadLine()); Book new_novel = new MyBook(title, author, price); new_novel.display(); }
public void AbstractBookTest() { using (StringWriter writer = new StringWriter()) { string title = "The Alchemist"; string author = "Paulo Coelho"; int price = 248; MyBook novel = new MyBook(title, author, price); string expectedOutput = $"Title: {title} Author: {author} Price: {price}"; Console.SetOut(writer); novel.display(); Assert.AreEqual(expectedOutput, writer.ToString()); } }
static void Main(String[] args) { Console.WriteLine("Title"); String title = Console.ReadLine(); Console.WriteLine("Author"); String author = Console.ReadLine(); Console.WriteLine("Price"); int price = Int32.Parse(Console.ReadLine()); Console.WriteLine(); // creates an instance of myBook based on console input Book new_novel = new MyBook(title, author, price); // prints the desired data to the console via the display method new_novel.display(); }
public void AbstractClassTest1() { String title = "The Alchemist"; String author = "Paulo Coelho"; int price = 248; string expectedTitle = "Title: " + title; string expectedAuthor = "Author: " + author; string expectedPrice = "Price: " + price.ToString(); Book new_novel = new MyBook(title, author, price); using (var sw = new StringWriter()) { Console.SetOut(sw); new_novel.display(); string[] actualResult = sw.ToString().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual(expectedTitle, actualResult[0]); Assert.AreEqual(expectedAuthor, actualResult[1]); Assert.AreEqual(expectedPrice, actualResult[2]); } }