Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 29th, 2003, 04:06 PM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default C#,chapter 8 excercise

I was trying to do question 4 and the question asks to supply parameters for the get method in order to imnplement the required function and overload it while the compiler doesnt let me do that and I believe that get method can't be overloaded or be supplied parameters.can anyone help?an example would help.
thankx.
Akbar

  #2 (permalink)  
Old October 6th, 2003, 11:36 PM
Authorized User
 
Join Date: Oct 2003
Location: Phoenix, Arizona, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Akbard,

I just wanted to let you know that I had a hard time with that one too. It just for some reason would not work, so I have a work around that I think is much better anyways. Here you go. I put this in its own class.

namespace Book_Object
{
    public class Book
    {
        public Book(string newTitle, int newISBN, decimal newPrice) // Class Constructor
        {
            title = newTitle;
            isbn = newISBN;
            price = newPrice;
            ukPrice = .25m;
            canPrice = .15m;
        }

        private string title; // title Variable
        private int isbn; // isbn Variable
        private decimal price; // price Variable
        private decimal ukPrice; // uk Price Variable
        private decimal canPrice; // canadian Price Variable

        public string US
        {
            get
            {
                return "US $" + Convert.ToString(price);
            }
        }

        public string UK
        {
            get
            {
                return "UK $" + Convert.ToString(ukPrice = price - (price * ukPrice));
            }
        }

        public string Can
        {
            get
            {
                return "CAN $" + Convert.ToString(canPrice = price + (price * canPrice));
            }
        }

        public string TitleInfo
        {
            get
            {
                return title + " <i>[ISBN: " + isbn + "] </i>";
            }
        }

        public string Title
        {
            get
            {
                return title;
            }
        }

        public int ISBN
        {
            get
            {
                return isbn;
            }
        }

    }
}


And now the other page looks like this


public class Book_Object : System.Web.UI.Page
    {
        private void Page_Load(object sender, System.EventArgs e)
        {
            Book MyBook = new Book("Beginning ASP.Net with C#", 1861007045, 39.99m);
            Response.Write("<b>New book 'MyBook' created.</b>");
            Response.Write("<br/>Title Info: " + MyBook.TitleInfo);
            Response.Write("<br/>" + MyBook.US + "<br/>");
            Response.Write(MyBook.UK + "<br/>");
            Response.Write(MyBook.Can + "<br/><br/>");

            Book AnotherBook = new Book("Professional ASP.Net 1.0 SE", 1861007035, 59.99m);
            Response.Write("<b>New book 'AnotherBook' Created.</b>");
            Response.Write("<br/>Title Info: " + AnotherBook.TitleInfo);
            Response.Write("<br/>" + AnotherBook.US + "<br/>");
            Response.Write(AnotherBook.UK + "<br/>");
            Response.Write(AnotherBook.Can + "<br/><br/>");


        }
}

I hope this helps you out.

Jason

"Is the glass half empty, half full, or twice as large as it needs to be?"

  #3 (permalink)  
Old October 7th, 2003, 03:25 AM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thnx jason. it was a lot of help and yeh the glass is twice as large as it needs to be...........heheheheh.cheers



Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2 - End of chapter exercises whizzkid1892 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 30th, 2008 12:02 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM
Excercise answers for book GrantWillie C# 0 October 22nd, 2003 05:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.