C# Homework. I am looking for an explanation of what is going on -


forgive me asking might think stupid questions. trying read code below , make sense out of it.

why novel.title used in main. understand title why novel.title used. other 1 holding title information entered user. same questions author, , level.

 using system;  using system.collections.generic;  using system.text;   namespace assignment6 { public class book {     protected string title;     public string title     {                 {             return title;         }         set         {             title = value;         }     }     protected string author;     public string author     {                 {             return author;         }         set         {             author = value;         }     }     public void showbook()     {         console.writeline("the book entered " + title + " " + author);     }     public book(string booktyp1, string booktyp2)     {         console.writeline("you enter data " + booktyp1 + " book indicating " + booktyp2 + " book.");         console.writeline();     } }  public class fiction : book {     private int level;     public int level     {                 {             return level;         }         set         {             level = value;         }     }     public void showfiction()     {         showbook();         console.writeline("reading level " + level);     }     public fiction()         : base("fiction", "reading level")     {     } }  public class nonfiction : book {     private int pages;     public int pages     {                 {             return pages;         }         set         {             pages = value;         }     }     public void shownonfiction()     {         showbook();         console.writeline(pages + " pages");     }     public nonfiction()         : base("nonfiction", "number of pages")     {     } }  public class assignment6 {     public static void main(string[] args)     {         char choice;          console.write("do want fiction (f) or non-fiction (n)? -->");         choice = convert.tochar(console.readline().toupper());         switch (choice)         {             case 'f':                 {                     fiction novel = new fiction();                     console.write("enter book title-->");                     novel.title = console.readline();                     console.write("enter book author-->");                     novel.author = console.readline();                     console.write("enter reading level-->");                     novel.level = convert.toint32(console.readline());                     novel.showfiction();                     break;                 }             case 'n':                 {                     nonfiction manual = new nonfiction();                     console.write("enter book title-->");                     manual.title = console.readline();                     console.write("enter book author-->");                     manual.author = console.readline();                     console.write("enter number of pages-->");                     manual.pages = convert.toint32(console.readline());                     manual.shownonfiction();                     break;                 }             default:                 {                     console.writeline("you made inappropriate entry -- closing program");                     break;                 }         }     }  }  } 

i sure here know how new programming. can love when works, hate when doesnt , makes me want quiet.

the

 protected string title; 

cant accessed directly, can access through :

public string title {         {         return title;     }     set     {         title = value;     } } 

notice title different title here, can novel.title no novel.title


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -