Here is a code which is for my homework. On line 10 I am having problem with double to float conversion and I am not sure why it is in place. Any tips please? PS. Code isn’t finished.
More info, it is about number 29.99 which is declared as float but here is in double form, I suppose.
using System;
namespace Lab_3
{
class BookTest
{
static void Main(string[] args)
{
Book book1 = new Book();
Book book2 = new Book("Advenced C#", "Joe", "Robertson", 29.99, "PUC Press");
}
}
public class Book
{
string authorFirstName;
string authorLastName;
float price;
string publisherName;
string title;
public Book()
{
}
public Book(string bookTitle, string firstName, string lastName, float bookPrice, string publisher)
{
authorFirstName = firstName;
authorLastName = lastName;
price = bookPrice;
publisherName = publisher;
title = bookTitle;
}
public void display()
{
}
public string getAuthorName()
{
return 0;
}
public string AuthorFirstName
{
get
{
return authorFirstName;
}
set
{
authorFirstName = value;
}
}
public string AuthorLastName
{
get
{
return authorLastName;
}
set
{
authorLastName = value;
}
}
public float Price
{
set
{
price = value;
}
}
public string PublisherName
{
set
{
publisherName = value;
}
}
public string Title
{
set
{
title = value;
}
}
}
}
EDIT:
Thanks for help! Problem is solved and explanation helped me cleared some things out.
Try