Sunday, February 27, 2011

General way of making class : Book

class Book
{
String title;
String author;
float price;
int cat, subCat;

public Book (String t, String a, int c1, int c2, float p)
{
title = t;
author = a;
price = p;
cat = c1;
subCat = c2;
}

public String details ()
{
return title+", "+author+" Category "+cat+"."+subCat+" value $"+price;
}

public String toString()
{
return "Title <"+title+"> Author <"+author+"> cat:"+cat+" subCat:"+subCat+" price:"+price;
}
}

No comments:

Post a Comment

Chitika