So basically, this is my project:
* Write a LibraryManager class that provides a GUI application to add, check out, look up the status of, and return books in a library.
The GUI compiles and executes perfectly. I just need to finish the code for the LibraryBook in order to make the GUI function correctly.
-------------------------------------
So here is what I've gotten so far. I'm having trouble trying to write the code to actually add the books to a Library(ArrayLi st). Do I need to create an arrayList first, if so, how do I do so? I have my GUI setup, I just need to figure out the code to go into the MouseClicked part as well as the rest of the code. I've gotten a good portion of the code written, I'm just not exactly sure how to put it all together. I'm obviously a novice, but this doesn't seem too difficult. Any help would be gladly appreciated. Thanks.
[SIZE=4]GUI[/SIZE]
import java.awt.*;
import java.awt.event. *;
import javax.swing.*;
import javax.swing.bor der.*;
import java.io.*;
import java.util.Strin gTokenizer;
import java.util.Array List;
import java.util.*;
public class LibraryManager extends JFrame implements LibraryBook
{
private JButton add, checkOut, status, returnBook;
private JTextField inputBox, totalBox;
private JLabel inputText;
private String theHolder, dueDate;
private String theISBN;
public LibraryManager ()
{
setDefaultClose Operation(EXIT_ ON_CLOSE);
setTitle("Virtu al Library");
setResizable(fa lse);
Container pane = getContentPane( );
pane.setLayout( new GridLayout(3,1) );
JPanel inputPane = new JPanel();
inputText = new JLabel("ISBN:") ;
inputPane.add(i nputText);
inputBox = new JTextField(30);
inputPane.add(i nputBox);
pane.add(inputP ane);
JPanel buttons = new JPanel();
add = new JButton("Add");
buttons.add(add );
checkOut = new JButton("Check Out");
buttons.add(che ckOut);
status = new JButton("Status ");
buttons.add(sta tus);
returnBook= new JButton("Return Book");
buttons.add(ret urnBook);
pane.add(button s);
pack();
}
public void mouseClicked(Mo useEvent e)
{
}
public void mouseEntered(Mo useEvent e)
{
}
public void mouseExited(Mou seEvent e)
{
}
public void mousePressed(Mo useEvent e)
{
}
public void mouseReleased(M ouseEvent e)
{
}
public static void main(String[] args)
{
LibraryManager lm = new LibraryManager( );
lm.setVisible(t rue);
}
}
-----------------------------------------------------
[SIZE=4]LibraryBook[/SIZE]
import java.util.*;
import java.text.*;
public interface LibraryBook
{
private String title, theHolder, isbn;
private GregorianCalend ar dueDate;
public LibraryBook(Str ing t, String i)
{
title = t;
isbn = i;
}
public String getTitle()
{
return title;
}
public String getHolder()
{
return theHolder;
}
public GregorianCalend ar getDueDate()
{
return dueDate;
}
public String getISBN()
{
return isbn;
}
public void checkIn()
{
theHolder = null;
dueDate = null;
}
public boolean checkOut(String holder)
{
if (theHolder == null)
{
theHolder = holder;
return true;
}
return false;
}
}
* Write a LibraryManager class that provides a GUI application to add, check out, look up the status of, and return books in a library.
The GUI compiles and executes perfectly. I just need to finish the code for the LibraryBook in order to make the GUI function correctly.
-------------------------------------
So here is what I've gotten so far. I'm having trouble trying to write the code to actually add the books to a Library(ArrayLi st). Do I need to create an arrayList first, if so, how do I do so? I have my GUI setup, I just need to figure out the code to go into the MouseClicked part as well as the rest of the code. I've gotten a good portion of the code written, I'm just not exactly sure how to put it all together. I'm obviously a novice, but this doesn't seem too difficult. Any help would be gladly appreciated. Thanks.
[SIZE=4]GUI[/SIZE]
import java.awt.*;
import java.awt.event. *;
import javax.swing.*;
import javax.swing.bor der.*;
import java.io.*;
import java.util.Strin gTokenizer;
import java.util.Array List;
import java.util.*;
public class LibraryManager extends JFrame implements LibraryBook
{
private JButton add, checkOut, status, returnBook;
private JTextField inputBox, totalBox;
private JLabel inputText;
private String theHolder, dueDate;
private String theISBN;
public LibraryManager ()
{
setDefaultClose Operation(EXIT_ ON_CLOSE);
setTitle("Virtu al Library");
setResizable(fa lse);
Container pane = getContentPane( );
pane.setLayout( new GridLayout(3,1) );
JPanel inputPane = new JPanel();
inputText = new JLabel("ISBN:") ;
inputPane.add(i nputText);
inputBox = new JTextField(30);
inputPane.add(i nputBox);
pane.add(inputP ane);
JPanel buttons = new JPanel();
add = new JButton("Add");
buttons.add(add );
checkOut = new JButton("Check Out");
buttons.add(che ckOut);
status = new JButton("Status ");
buttons.add(sta tus);
returnBook= new JButton("Return Book");
buttons.add(ret urnBook);
pane.add(button s);
pack();
}
public void mouseClicked(Mo useEvent e)
{
}
public void mouseEntered(Mo useEvent e)
{
}
public void mouseExited(Mou seEvent e)
{
}
public void mousePressed(Mo useEvent e)
{
}
public void mouseReleased(M ouseEvent e)
{
}
public static void main(String[] args)
{
LibraryManager lm = new LibraryManager( );
lm.setVisible(t rue);
}
}
-----------------------------------------------------
[SIZE=4]LibraryBook[/SIZE]
import java.util.*;
import java.text.*;
public interface LibraryBook
{
private String title, theHolder, isbn;
private GregorianCalend ar dueDate;
public LibraryBook(Str ing t, String i)
{
title = t;
isbn = i;
}
public String getTitle()
{
return title;
}
public String getHolder()
{
return theHolder;
}
public GregorianCalend ar getDueDate()
{
return dueDate;
}
public String getISBN()
{
return isbn;
}
public void checkIn()
{
theHolder = null;
dueDate = null;
}
public boolean checkOut(String holder)
{
if (theHolder == null)
{
theHolder = holder;
return true;
}
return false;
}
}
Comment