Question: C#: Write 2 new methods named assignBook and assignWriter. assignBook should assign a book to a contract, similar to the assignEditor. assignWriter should assign a
C#:
Write 2 new methods named assignBook and assignWriter. assignBook should assign a book to a contract, similar to the assignEditor. assignWriter should assign a writer to a book. I started on it but need help fixing it
using System; using System.Collections.Generic; using System.Text;
namespace PublishingHouse { public class Publisher { public String Name { get; set; } private List _editors; private List _writers; private List _contracts; private List _books; public String EditorRoster { get { String tempString = ""; foreach(Editor editor in _editors) { tempString += editor.FullName + " "; } return tempString; } }
public String WriterRoster { get { String tempString = ""; foreach(Writer writer in _writers) { tempString += writer.FullName + " "; } return tempString; } }
public String ContractList { get { String tempString = ""; foreach(Contract contract in _contracts) { tempString += contract + " "; } return tempString; } }
public String BookList { get { String tempString = ""; foreach(Book book in _books) { tempString += book + " "; } return tempString; } }
public Publisher() : this("No Name") { } //Designated Constructor public Publisher(String name) { Name = name; _editors = new List(); _writers = new List(); _contracts = new List(); _books = new List(); }
public void addEditor(Editor editor) { _editors.Add(editor); }
public void addWriter(Writer writer) { _writers.Add(writer); }
public void addContract(Contract contract) { _contracts.Add(contract); }
public void addBook(Book book) { _books.Add(book); }
public void assignEditor(int contractNumber, String editorFirstName, String editorLastName) { // Find the contract using the contractNumber // Find the editor using the first name and last name
contract.Editor = editor; //This is the last line of the method.
} public void assignBook(int contractNumber, String title, String author) {
if (contract.ContractNumber === contractNumber) { contract.Book = book; } }
public void assignWriter(String title, String author, String writerFirstName, String writerLastName) { if (book.FirstName === writerFirstName && book.lastName === writerLastName) { book.Writer = writer; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
