How do you add a membership records in java(bluej) First Name, Last Name, phone number. Please can you help me

Recommended Answers

All 18 Replies

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"

Post what you have done so far and someone will help you from there.

I'm assuming that because you are using BlueJ, you are in your first semester of a Computer Science Course or related course. On this assumption I am going to recommend you talk to a tutor or to some class mates as the question seems to be related to a specific piece of code provided by your tutor.

Do you mind if you help i will send what i have done and plus assignment.

Post what you have done here and someone will help. Explain where you are getting stuck - more more info you give the better we can help.

public class Book
        // The fields.
    private String author;
    private String title;
    private int pages;
    private String refNumber;
    private int identityNumber;

 * Set the author and title fields when this object 
public Book(String bookAuthor,String bookTitle,int bookPages,String bookrefNumber, int bookIdentityNumber)
    author = bookAuthor;
    title = bookTitle;
    pages = bookPages;
    refNumber = bookrefNumber;
    identityNumber = bookIdentityNumber;


public String getbookAuthor()
    return author;

public String getTitle()
    return title;

public int getPages()
    return pages;

public String printAuthor()
    return author;

public String printTitle()
    return title;

public int printPages()
    return pages;

public void printDetails()

    System.out.println("bookAuthor: " +author);
    System.out.println("Book title: " +title);
    System.out.println("pages: " +pages);

1. book records
   a. add a new book
   b. for a given book id number print the book details
   c. print a list of books

   2. membership records
   a.add a new member
   b.member id number print the member detail
   c. print all members

   Can you explain to me how i can do this because i am stuck and new to this. I would appreciate the help please.

1a you can't add a book in the book class.
instantiate it in your main method, and add it to an array or a list.
1b on your instance of book, call the printDetails method
1c iterate over your array or list, printing the info of each of them

question two is basically identical.

So in small steps can you explain to me because i am new please. Can you explain the structure to me as well.

Ok, Imagine an actual physical book.

This is what you are trying to describe in your class. Whenever we program in Object Oriented Programming 'OOP', we try to Describe and Model real world Objects.

So let's start,

All books have an Author, a Title, Pages, Reference Numbers and Identity Numbers.

These are the properties of a Book, we put these in the fields of the class. The Fields are the variables placed at the top of the class e.g private int pages

Next we have Methods. These are ways of manipulating the Book object.

There are two types of Methods, Accessors and Mutators. Accessors GET information and therefire have a Return statement. Mutators change/mutate the data.

The idea behind OOP is to be able to write the description of something once and implement it many times. So we have written a Book class, and now we can use it to make 1000 books or more if we please.

Hopefully this has clued you up more on the aim of a Class.

There are things here that you cannot do, e.g. add a Book to a Book, you need to have another class that maintains a Collection of Books (e.g a Library)

I think this is all the information I can give due to the nature of the forum where I cannot help you first hand. If you still have problems with coding, I'd recommend getting the 'Objects First with Java' book written by Kolling and Barnes. These are the people who wrote blueJ and their book is very informative with lots of good examples.

Hope this was helpful

Good Luck

So the public class book and the field/method go into the library.

depends on how you mean. most likely, your library class will have a list or an array in which you store books, but Book will still be a seperate class

I have done this   Book - Public class book
                   Libray - Public Class library
                   Membership - Public Class Membership

And where does the arraylist goes to keep my records.                   

How do i store the book records by using arraylist can you show me an example please. For example to store a book in library

This is not a "we do your homework" service. Try to solve your problems yourself before asking for help. For example, 30 seconds with Google will give you all kinds of information and examples of using ArrayLists. Before asking for any more help, show that you have made some effort yourself first.

how would you return a member with a paticular IDV number

Search all the members until you find the right one, then return it?

I think the biggest barrier to overcome here is that you are not fully understanding the role of an Object in programming. I wrote a small article on my new blog a few days ago about this. It's shameless I know, but have a little look, it may help.

If that doesn't help then go and buy the Objects First with BlueJ book. It's written by the professors who created BlueJ. It's a really good guide from basics all the way up to moderately complex code. Worth the money!!

Hope this advice helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.