DEAR JAVA EXPERTS.

can u help me? i dont know how to do the next move....
i want to write code that can make each object of the class Book can hold the following information about a book: title, up to four authors, publisher, ISBN, price, and number of copies in stock. To keep track of the number of author add another instance variable.

Include the methods to perform various operations on the objects of Book. For example, the usual operations that can be performed on the title are to show title, set the title, and check whether the title is the actual title of the book. Similarly, the typical operations that can be performed on the number of copies in stock are to show the number of copies in stock, set the number of copies in stock, update the number of copies in stock and return the number of copies in stock. Add similar operations for the publisher, ISBN, book price and authors. Add the appropriate constructors.

Design a class Member, in which each object of Member can hold the name of a person, member ID, number of books bought and amount spent. Include the methods to perform various operations of the class Member – for example, modify, set and show the person’s name. Similarly update, modify and show the number of books bought and amount spent. Add appropriate constructors.

Using the class Book and Member, write a program to simulate a bookstore. The bookstore has two types of customers: those who are members of the bookstore and those who buy books from the book store only occasionally. Each member has to pay RM10 as yearly membership fees and receives a 5% discount on each book bought.

For each member, the bookstore keeps track of the number of books bought and the total amount spent. For every eleventh book that a member buys, the bookstore takes the average of the total amount of the last 10 books bought, applies this amount as a discount, and then reset the total amount spent to 0.

this is my code that i cant proceed...

import java.io.*;
import java.util.StringTokenizer;

/**
The TestScoreReader class reads test scores as
tokens from a file and calculates the average
of each line of scores.
*/

public class Book
{
private FileReader freader;
private BufferedReader inputFile;
private String line;

/**
The constructor opens a file to read
the grades from.
@param filename The file to open.
*/

public Book(String filename) throws IOException
{
freader = new FileReader(filename);
inputFile = new BufferedReader(freader);
}

/**
The readNextLine method reads the next line
from the file.
@return true if the line was read, false
otherwise.
*/

public boolean readNextLine() throws IOException
{
boolean lineRead; // Flag variable

// Get the next line.
line = inputFile.readLine();

// Determine whether the line was read.
if (line != null)
lineRead = true;
else
lineRead = false;

return lineRead;
}

public String tokenTime() throws IOException
{
String name;
String author;
String publisher;
String isbn;
String price;
String str;
StringTokenizer token = new StringTokenizer(line, ",");

name = token.nextToken();
author = token.nextToken();
publisher = token.nextToken();
isbn = token.nextToken();
price = token.nextToken();
str = "Name: " + name +
"\nAuthor: " + author +
"\nPublisher: " + publisher +
"\nISBN: " + isbn +
"\nPrice: RM" + price;
return str;
}


/**
The close method closes the file.
*/

public void close() throws IOException
{
inputFile.close();
}
}

the body...

import java.io.*; // Needed for IOException
import javax.swing.JOptionPane;

/**
This program uses the TestScoreReader class
to read test scores from a file and get
their averages.
*/

public class Demo
{
public static void main(String[] args) throws IOException
{
// Create a TestScoreReader object.
Book scoreReader = new Book("as.txt");
Member member = new Member("mem.txt");

// Display the averages.
while (scoreReader.readNextLine())
{
JOptionPane.showMessageDialog(null, scoreReader.tokenTime() , "BOOK", JOptionPane.INFORMATION_MESSAGE);
while (member.readNextLine())
{
//JOptionPane.showMessageDialog(null, member.tokenTime() , "MEMBER", JOptionPane.INFORMATION_MESSAGE);
}
}

// Close the TestScoreReader.
scoreReader.close();
}
}

the books is refer to here...

Starting Out with Java, Gaddis and Muganda, Pearson, 890-345-566, 76.90
Modul Hubungan Etnik, Shamsul Amri Baharudin, Pusat Penerbitan Universiti(UPENA), 234-234-344, 20.00


and this is for the member

import java.io.*;
import java.util.StringTokenizer;

/**
   The TestScoreReader class reads test scores as
   tokens from a file and calculates the average
   of each line of scores.
*/

public class Member
{
   private FileReader freader;
   private BufferedReader inputFile;
   private String line;

   /**
      The constructor opens a file to read
      the grades from.
      @param filename The file to open.
   */

   public Member(String filename) throws IOException
   {
      freader = new FileReader(filename);
      inputFile = new BufferedReader(freader);
   }

   /**
      The readNextLine method reads the next line
      from the file.
      @return true if the line was read, false
      otherwise.
   */

   public boolean readNextLine() throws IOException
   {
      boolean lineRead; // Flag variable

      // Get the next line.
      line = inputFile.readLine();

      // Determine whether the line was read.
      if (line != null)
        lineRead = true;
      else
         lineRead = false;

      return lineRead;
   }

   public String tokenTime() throws IOException
   {
	   String str;
	   String name;
	   String memberID;
	   String noBooks;
	   String amountSpent;
	   StringTokenizer token = new StringTokenizer(line, ",");

	   name = token.nextToken();
	   memberID = token.nextToken();
	   noBooks = token.nextToken();
	   amountSpent = token.nextToken();

	   str = "Name: " + name +
	         "\nID: " + memberID +
	         "\nNo of books bought: " + noBooks +
	         "\nAmount Spent: " + amountSpent;
	   return str;
   }


   /**
      The close method closes the file.
   */

   public void close() throws IOException
   {
      inputFile.close();
   }
}

please help mee...

If each book needs each of those variables, you need to do sometihg like, String ISBN = "<ISBN code>", and ect for each variable, and have a public String getISBN() { return ISBN; } and do the same for each variable that each class needs

What do you need help with? Ask specific questions to get help, don't just post your project description and your code. Just let me know what part of the code you're having trouble with and what you aren't understanding and I will be glad to help. If you have any compiler errors, post them. And post your code in code tags next time, see the stickies for how to do this.

i'm sorry for what i just did..
qbut i dont know what to do next

i dont know how to add or delate membership for the bookstore and do the discount for the member purchase.

not just that,i also dont know how to display the books or members information like the isbn, book price ect just by key-in the id number or book title. how to combine the GUI and I/O?

i tihnk i still dont understand Java..tihs is just the introductionJavaAssignment but i cant do it.

can u help me or give me any java tutorial notes or website that can help me??...please

Adding or removing depends on how you are storing things to begin with. If you are just storing a book in a variable, you could set the variable to null to 'remove it'. If you are storing things in an array of books, you would have to remove the book from the array's index. You should read the sticky at the top of this forum, it links to many helpful Java Tutorials. Read one of them.

This article has been dead for over six months. Start a new discussion instead.