OO Design For Library - Maintaining Records Of Books And Members?

Jul 8, 2014

I was trying to come up with the design for a library. Here are the requirements:

The library maintains a record of books and its members. It allows members to check out books. Books can be searched by author name or title. The books are classified into 4 categories - General, Sports, Politics, Business.

I've come up with this initial design:

Classes:

Category (enum)BookMemberLibrary
Category
Attributes: SPORTS, GENERAL, POLITICS, BUSINESS
Book
Attributes: String title, String authorName, Category category, boolean checkedOut

[Code] .....

View Replies


ADVERTISEMENT

Java EE SDK :: Can Use Filter For Maintaining Session Timeout Related Functionality

Dec 14, 2011

I want to implement session timeout functionality ...so with web.xml file i can specify session timeout ..say 30 min.. Now with filter is it possible for me to redirect the request to login page after session is timeout say after 30 min... What are the other ways...??

Also i want to know whether timeout setting in web.xml will overweight the application server timeout ... I am using struts 1.0 and hibernate...

View Replies View Related

Count Number Of Books In Arraylist?

Jan 29, 2015

We have been given an assignment to create a small library, with the following classes Library, Book, Author and Copy. With a given class Biblio which has predefined code and adds the books to the class book in an arraylist in Class Copy.

The UML Domain is attached so you know the flow of the classes Everything is working fine and the generated output is correct.

There is just one method in class Library that is not working, the int method has to count the number of Copy's based on the Class Book (String):

I have to go through the Arraylist in Class Copy and look for a specific book and return the number of copy's.

I have tried multiple steps using a for loop Now I have found a similar post the uses hashset, I have tried below code but the return comes back with 0. (There are 3 copy's)

package domein;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import domein.Boek;
import domein.Exemplaar;

[code]....

View Replies View Related

Calculation - Sorting Books By Rating

Jun 19, 2014

I have a calculation that sorts books by rating...

System.out.println("
" + "
Sorted by Rating
");
  for (int count = 0; count < bookL.size(); count++) {
for (int in = 0; in < bookList.size() - 1; in++)
if (videoList.get(in).getRating() < bookList.get(in + 1).getRating()) {

[Code] ....

What am I missing here? Why doesn't this work?

View Replies View Related

Adding Records To A File Then Searching That File For Records

Jan 30, 2015

The assignment is to create a program that accepts entries from a user for 3 variables then saves the data to a file. There are other programs that use the file created. One program displays the non-default records. The next program allows the user to enter the id for the employee and displays the first and last name for that id number. The last program allows the user to enter a first name. It then displays all id numbers and last names for records with that first name.

Given the above situation, I am stuck on creating the first program. I can make the text file and write the information to it. However, when the file is created, a space is placed in between each entry for some reason. I cannot figure out how to get rid of this space so that I can display the appropriate records for the remaining programs. Below is the code and a view of my problem.

import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.*;
import java.io.*;
import static java.nio.file.StandardOpenOption.*;
import java.util.*;
public class WriteEmployeeList {

[Code] .....

The values for nameFormat and lnameFormat are 10 spaces. This is how the book told me to make sure everything is uniform and searchable. The file contents look like this when viewed in notepad.

000, ,
000, ,
000, ,
000, ,
000, ,

123,Justin,Slacum
124,Justin,Jones
125,James,Smithy
126,Jake,Flabernathy
127,John,Panakosfskee
128,SuzetteMae,Ginther

000, ,
000, ,
000, ,
000, ,
000, ,
000, ,
000, ,

View Replies View Related

Show Up Amount For Multiple Photo Books

Oct 9, 2014

import java.util.Scanner;
public class LM6Assignment
{
public static void main(String[] args)
{
Scanner inputDevice = new Scanner(System.in);
int numBooks = 0;
double onePhotoBook = 10.99;//each book cost 10.99
double costof1Book;
//mehtod calls
costof1Book = computeBill(onePhotoBook);

[Code] ....

How to code it so I can put in how many books they need and for it to show up with the amount for multiple photo books..

View Replies View Related

EJB / EE :: Maintaining Values From Primefaces Form After Form Submit

Jan 29, 2015

I have a form containing several fields, 2 of which persist to different table in a database than the rest of the fields on the form. I have no problem persisting the data into both tables of the database, and after the form is submitted I reset the form to its default values. That all works fine.

But in the same session, when I open another form (a search form) and enter search criteria, which then displays a datatable containing the search results, those 2 values that are persisted to another table are not showing up, but the rest of the data is.

Here is the method that calls the persist methods:

@ManagedBean(name = "foreignPartyController")
@SessionScoped
public class ForeignPartyController implements Serializable {
...
public void saveData() {

[Code].....

The values do show up, but the problem is, when a subsequent form is opened in the same session (e.g. a search form) the field for that value shows the actual value, instead of the field being blank.'

I am not sure why the data from the one database ("parent") is showing up, yet the data from the other database ("child") is not.

Is it something I am doing wrong? I thought by setting the setter in the child controller class back to a new instance of the Entity class (PolicyPayment) that it would reset the form to default values, but at the same time retain (or save) the inputted values in the same session.

View Replies View Related

Importing Static Members Of A Class

May 11, 2014

When importing static members of a class. Why are they only accessible within the constructor of the calling class, and not outside of it? Here's the source code to understand my question.

package Certification;
public class ExamQuestion {
static public int marks ;
static public void print(){
System.out.println(100);

[Code] ....

View Replies View Related

Private Members Cannot Be Accessed In Derived Class

Jul 3, 2014

When we say derived class that means copy of base class plus subclass specific implementations. But when it comes to private members it cannot be accessible in subclass scope. Does it mean byte code generated for subclass doesn't has byte code of private members of super class ?

View Replies View Related

Accessing Of Static Members Using Null Reference

Mar 21, 2014

Why static member are allowed to be accessed with class-name and a null reference?

Here's the given code.

class Employee{
public static Integer companyId = 1001; // this could be private.
public static Integer getCompanyId(){
return Employee.companyId;
}
//a setter method will be here if the companyId will be private.
}
public class TestStatic{
public static void main(String[] args){
Employee emp =null;
emp.companyId = 11111;
System.out.println(emp.getCompanyId());
}
}

In this code the static members of a class are accessible by the null reference of that class.

These can also be access by the class (Employee.companyId or Employee.getCompanyId()).

What is the difference here in both. why a null reference can access these static members.

View Replies View Related

Two Classes - How To Use Members Of Color Class Without Using Extends

Nov 4, 2014

I have two classes in two different files.

Color.java and Light.java

The Color class:

public class Color {
private int red;
private int green;
private int blue;
public Color(){
red = 0;
green = 0;
blue = 0;
}

And i have the Light class :

public class Light {
private Color color1;
private boolean switchedon;

public Light(int red, int green, int blue){
//dont know what to write here . how can i use the members of the Color class here ? without using extends.
}
}

View Replies View Related

How To Achieve Runtime Polymorphism By Data Members

Apr 19, 2014

can we achieve runtime polymorphism by data members?

View Replies View Related

How To Create Public Get And Setter Methods For Private Members Of The Class

Mar 23, 2015

If i have a class(lets say class name is Approval) with the following private members: String recip_id, Int accStat, String pDesc, String startDate How can i create public get and setter methods for these private members of the class?

View Replies View Related

ASCII Animation Program - Accessing Data Members From Different Classes

Nov 12, 2014

I have a problem with this ascii animation program I am working on. I declared a method inside of my class AsciiAnimation extends JFrame implements ActionListener, called

package AsciiAnimation;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
 import javax.swing.*;
 public class AsciiAnimation extends JFrame implements ActionListener{
int currentFrame = 0;
ArrayList<String> frameList = new ArrayList<String>();

[Code] ....

Basically I just am trying to figure out how java works with me accessing those 2 data members, currentFrame and frameList inside of my first class ALL in the same package.

View Replies View Related

Implement Equality And HashCode Method If Class Has Reference Type Members?

Jan 16, 2015

I am trying to implement the following example to override the equality and hashCode method if the class has reference type member. I do get the expected result "true" for equal and "false" for non-equal objects. But the print statement in the Circle's equal method is not executed when the objects values are not equal. I don't know what i am missing, though i get the equality result "false" as expected for non equal objects.

class Point{
private int x, y;
Point (int x, int y) {
this.x =x;
this.y = y;

[code]....

View Replies View Related

Swing/AWT/SWT :: Adding Records Using AbastractTableModel?

Feb 2, 2014

I'm starting to use AbstractTableModel to customize a JTable model. The problem appears when you add a record from a ResultSet to JTable object.

I've managed to insert records, but empty, I need that for every column I can see the data is there.

Leave some code I have been writing ... the method to insert records in JTable is called "insertEmptyRow" (for now).

I need some opinion that can make changes to the code of this method so you can get to see all the data in a record.

MyFirstModel:

public class TablaModeloPrincipal extends
private String algo;
private int numRegTabla;
//Agrego las columnas que quier tener en el model
private String[] columnNames = {"DNI", "Nombre", "Edad", "Dirección", "Empresa", "Contacto"};
Vector<String[]> clientes = new Vector<String[]>() ;
public ResultSet buscarResultset() throws SQLException{
ResultSet rs=null;

[code]....

View Replies View Related

Sending XML Records To Sax Parser Using Buffer

Mar 26, 2014

i am having a below piece of code in my worker thread. In my output i am getting xml records from the database. I'm sending this output to a input stream & finally to a sax parser.My query is, before sending to the parser i need to store the input stream in buffer. The buffer should store 1000 records. For every 1000 records the parser should be called from buffer.

while (orset.next()) {
output = orset.getString("xmlrecord");
writeCount++;
InputStream in = new ByteArrayInputStream(output.getBytes("UTF-8"));
InputStream inputStream = new ByteArrayInputStream(output.getBytes("UTF-8"));
Reader reader = new InputStreamReader(inputStream,"UTF-8");

[code]....

View Replies View Related

Reload Array With Records In A File

Apr 19, 2014

I am working on a project and for one step, I need to load an array (which in this case, students[]), with the records in another file.

So, should I used the try, catch method?? I am just not sure about the array. I know how to read from a file, but, I didn't get the idea of loading an array.

View Replies View Related

HashTable Insertion - Duplicate Records

Apr 20, 2015

I am having some difficulty adding a new item to the HashTable when a collision occurs. We can only use the basic utilities to code this, so we are coding a HashTable by hand. We have an array of length of 10, which each index holds or will hold a Node for a Linked List.

The code hashes fine, adds the item, but the problem exists when adding items that already been hashed. The project is much bigger, but this is the engine behind the rest, and I figured I would tackle this first.

The items we are adding are objects which are states containing different information, we hash based on the ASCII sum % tableSize.

Here is the code I am testing with to add items:

HashTable ht = new HashTable(10);
State az = new State("Arizona","AZ","W",2,"Y",2);
State fl = new State("Florida", "FL", "F", 2, "X", 2);
State hi = new State("Hawaii", "HI", "H", 3, "Z", 1);
State al = new State("Alabama", "AL", "A", 5, "W", 0);
ht.insert(hi);

[Code] ....

View Replies View Related

Servlets :: Access List Of Database Records Using JSP?

Apr 3, 2014

How we can get the list of records from database my sql using jsp pages and servlets so that it show results on webpage.

View Replies View Related

Write Multiple Records To A File - Why Does This Keep Overwriting

Oct 27, 2014

So I am calling this method several times and trying to write multiple records to a file. Problem is that every time I call the method it overwrites the file from before and doesn't add it.

public void fileWriterMethod() throws IOException{
RandomAccessFile raf = new RandomAccessFile(filename, "rw");
raf.writeInt(id);
raf.writeInt(existingMileage);
raf.writeInt(gasCost);
raf.writeInt(ndays);
raf.writeInt(rate);

[Code] ....

View Replies View Related

Reading Records From TXT File And Storing It Into Array

Apr 15, 2014

I am reading records from a txt file and storing it into an array

import java.util.*;
import java.io.*;
 public class PatientExercise {
//patients exercise time
public static void main (String[]args) throws IOException{
Scanner in = new Scanner(new FileReader("values.txt"));
double [] patientTimeRecords = new double [300];
int noExerciseCount=0, numPatients =0;
double highest=0, lowest=0, avg=0, totalTime=0;
 
[Code] ....

However an error msg keeps popping up:

Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:907)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextDouble(Scanner.java:2456)
at pastpapers.PatientExercise.main(PatientExercise.ja va:44)

line 44 is:patientTimeRecords[i]= in.nextDouble();

View Replies View Related

Using Method In Eclipse IDE - Adding Records In Database

Sep 7, 2014

I am very confused about why my code is not working.. The function of my code will add records in my database (MySQL), Swing components of my frame..

btnUserAdd = jButton
txtUname, txtPword, txtLname, txtFname, txtMname, txtEmpNo = jTextField
cbAccType = jComboBox
EmpNo, Uname, Pword, Lname, Fname, Mname, AccType = MySQL fields

I created a method to be called when btnUserAdd is clicked. here is the code for the method:

public void UserAdd(){
String sql = "SELECT * FROM User WHERE Uname = ? and EmpNo = ?";
try {
pst = conn.prepareStatement(sql);

[Code] ....

the error is that it does not add the record it will display JAVA.LANG.NULLPOINTEREXCEPTION...

View Replies View Related

JSF :: Data Table Showing Records In Columns?

Aug 2, 2014

I'm new in JSF, so maybe this is a very simple problem:

My small application uses 'primefaces ' and I'd like to display the course of some laboratory values this way:

Parameter2014-08-022014-08-012014-07-31
Natrium [mmol/l]140.0135.0135.5
Calcium [mmol/l]2.12.02.3
Kalium [mmol/l]4.34.05.3
[...] [mmol/l]1.32.02.3

Data is stored in a per day manner, so each table column shows one record.

In JSF, I've only seen tables showing records in rows. How to display a transposed data table in JSF.

View Replies View Related

JSP :: Viewing / Inserting And Updating Records In Same Page

Dec 10, 2014

I need to view, update and insert records through a jsp page.example: Employee details..If we give an admission number of an employee, and if the admission number exists in the database then the details like Name, DOB, DOR, Address, Contact info should be displayed in the appropriate fields.(simply a select query in SQL) . The fields are editable and if we need to make any changes we can update in that details itself. If admission number doesn't exists means we can insert all the details except the admission number and a temporary admission number is generated and displayed. The problem with this is i can't able to revert it to the same page.

View Replies View Related

JDBC :: CLOBs - Retrieve Set Of Records Via Ref Cursor

May 21, 2015

I am working on a Java program that calls a stored procedure in an Oracle 11.2g database and retrieves a set of records via a ref cursor. The program follows the standard Connection/CallableStatement/ResultSet pattern. A ResultSet object is used to access and iterate through the returned cursor, processing each record in turn.
 
One of the database fields returned in the cursor is a CLOB, which I'm retrieving using the NClob class's getNClob() method. Two other methods - length() and getSubString() are then used to get the length of the CLOB and copy of it off to a String object respectively.
 
The problem is that these latter two method calls are relatively slow, taking around 80ms to complete for modestly sized CLOBs of, say, around 10KB in size.
 
Is this the most efficient way to access a CLOB and retrieve its contents? If so, is there anything I can do, to make it run faster?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved