vault backup: 2024-03-05 13:01:43

This commit is contained in:
2024-03-05 13:01:43 +00:00
parent 8f7a395bdb
commit 8ce640b4ba
44 changed files with 1177 additions and 177 deletions

View File

@@ -7,16 +7,6 @@
"id": "74175e978d06be55", "id": "74175e978d06be55",
"type": "tabs", "type": "tabs",
"children": [ "children": [
{
"id": "6ff62909f822ba9b",
"type": "leaf",
"state": {
"type": "pdf",
"state": {
"file": "Semester 2/Database Systems/Exercise Booklet.pdf"
}
}
},
{ {
"id": "90e6fc52439b47f9", "id": "90e6fc52439b47f9",
"type": "leaf", "type": "leaf",
@@ -37,8 +27,7 @@
"state": {} "state": {}
} }
} }
], ]
"currentTab": 1
}, },
{ {
"id": "1177e1c9853f407d", "id": "1177e1c9853f407d",
@@ -53,8 +42,19 @@
"file": "Semester 2/Database Systems/Exercise Booklet.pdf" "file": "Semester 2/Database Systems/Exercise Booklet.pdf"
} }
} }
},
{
"id": "e96e468fb0a709e5",
"type": "leaf",
"state": {
"type": "pdf",
"state": {
"file": "Semester 2/Database Systems/Booklet of Lecture Slides for Semester Two (2).pdf"
}
}
} }
] ],
"currentTab": 1
} }
], ],
"direction": "vertical" "direction": "vertical"
@@ -121,7 +121,7 @@
"state": { "state": {
"type": "backlink", "type": "backlink",
"state": { "state": {
"file": "Semester 2/Database Systems/Week 7/Week 7 Database Systems.md", "file": "Semester 2/Database Systems/Booklet of Lecture Slides for Semester Two (2).pdf",
"collapseAll": false, "collapseAll": false,
"extraContext": false, "extraContext": false,
"sortOrder": "alphabetical", "sortOrder": "alphabetical",
@@ -138,7 +138,7 @@
"state": { "state": {
"type": "outgoing-link", "type": "outgoing-link",
"state": { "state": {
"file": "Semester 2/Database Systems/Week 7/Week 7 Database Systems.md", "file": "Semester 2/Database Systems/Booklet of Lecture Slides for Semester Two (2).pdf",
"linksCollapsed": false, "linksCollapsed": false,
"unlinkedCollapsed": true "unlinkedCollapsed": true
} }
@@ -161,7 +161,7 @@
"state": { "state": {
"type": "outline", "type": "outline",
"state": { "state": {
"file": "Semester 2/Database Systems/Week 7/Week 7 Database Systems.md" "file": "Semester 2/Database Systems/Booklet of Lecture Slides for Semester Two (2).pdf"
} }
} }
}, },
@@ -201,22 +201,25 @@
"switcher:Open quick switcher": false "switcher:Open quick switcher": false
} }
}, },
"active": "90e6fc52439b47f9", "active": "e96e468fb0a709e5",
"lastOpenFiles": [ "lastOpenFiles": [
"Semester 2/Database Systems/Week 7/Week 7 Database Systems.md",
"Semester 2/Programming 2/Project/Part 2/Book.java#",
"Semester 2/Programming 2/Project/Part 2/Periodical.java#",
"Semester 2/Programming 2/Project/Part 2/LibraryItem.java#",
"Semester 2/Programming 2/Project/Part 2/Library.java#",
"images/Pasted image 20240227171728.png",
"images/Pasted image 20240227171700.png",
"Semester 2/Database Systems/Booklet of Lecture Slides for Semester Two (2).pdf",
"images/Pasted image 20240227171626.png",
"images/Pasted image 20240227162324.png", "images/Pasted image 20240227162324.png",
"images/Pasted image 20240227161946.png", "images/Pasted image 20240227161946.png",
"images/Pasted image 20240227161426.png", "images/Pasted image 20240227161426.png",
"Semester 2/Database Systems/Exercise Booklet.pdf", "Semester 2/Database Systems/Exercise Booklet.pdf",
"Semester 2/Database Systems/Booklet of Lecture Slides for Semester Two (2).pdf",
"Semester 2/Database Systems/Week 7/Week 7 Database Systems.md",
"images/Pasted image 20240227133544.png", "images/Pasted image 20240227133544.png",
"images/Pasted image 20240227133521.png", "images/Pasted image 20240227133521.png",
"images/Pasted image 20240227132816.png", "images/Pasted image 20240227132816.png",
"images/Pasted image 20240227132741.png", "images/Pasted image 20240227132741.png",
"images/Pasted image 20240227132007.png",
"images/Pasted image 20240227131954.png",
"images/Pasted image 20240227131936.png",
"images/Pasted image 20240227131321.png",
"Semester 2/Database Systems/Week 7", "Semester 2/Database Systems/Week 7",
"Semester 2/Database Systems/Week 6/Week 6 Database Systems.md", "Semester 2/Database Systems/Week 6/Week 6 Database Systems.md",
"Semester 2/Computer Systems Internals & Linux/Week 6/Week 6 Computer Systems Internals.md", "Semester 2/Computer Systems Internals & Linux/Week 6/Week 6 Computer Systems Internals.md",
@@ -228,10 +231,6 @@
"Semester 2/Programming 2/Assessment 3 Revision", "Semester 2/Programming 2/Assessment 3 Revision",
"Semester 2/Database Systems/Week 5/Week 5 Database Systems.md", "Semester 2/Database Systems/Week 5/Week 5 Database Systems.md",
"Semester 2/Database Systems/Week 6", "Semester 2/Database Systems/Week 6",
"Semester 2/Programming 2/Project/Part 2/Library.java#",
"Semester 2/Programming 2/Project/Part 2/Periodical.java#",
"Semester 2/Programming 2/Project/Part 2/data/item_data_2.txt",
"Semester 2/Programming 2/Project/Part 2/data/item_data_1_v2.txt",
"Semester 2/Database Systems/Week 4/Week 4 Database Systems.md", "Semester 2/Database Systems/Week 4/Week 4 Database Systems.md",
"Semester 2/HCI/Week 2/Week 2 Human Computer Interfaces.md", "Semester 2/HCI/Week 2/Week 2 Human Computer Interfaces.md",
"Semester 2/HCI/Week 3/Week 3 Human Computer Interfaces.md", "Semester 2/HCI/Week 3/Week 3 Human Computer Interfaces.md",

View File

@@ -102,12 +102,149 @@ Several issues that DBMS needs to address
| T1 | X | | | T1 | X | |
| T2 | Z | | | T2 | Z | |
| T3 | | Z | | T3 | | Z |
![](Pasted%20image%2020240227161426.png) ![](Pasted%20image%2020240227161426.png)
3. ![](Pasted%20image%2020240227161946.png) 1. ![](Pasted%20image%2020240227161946.png)
There is no deadlock since there are no cycles. There is no deadlock since there are no cycles.
4. ![](Pasted%20image%2020240227162324.png) 2. ![](Pasted%20image%2020240227162324.png)
There may be a deadlock, since there are multiple cycles in the WFG There may be a deadlock, since there are multiple cycles in the WFG
# Database Recovery Part 1 # Database Recovery Part 1
Database recovery is the process of restoring the database to a correct state after a failure
## Types of Failures
- Media Failures
- Hard Disk head crashes
- Loss of secondary storage
- System Crashes
- Hardware or software errors
- Results in loss of primary storage ( RAM )
- Application software errors
- Logical errors in programs that access the database
- Causes one or more transactions to fail
- Carelessness
- Unintentional destruction of data by users or operators
- Sabotage
- Intentional corruption or destruction of data, hardware, or software facilities
- Natural disasters
- Fires, floods, solar flares, earthquakes, power failure, bit flips, etc.
## Facilities Required for Recovery
Log File ( Journal )
- Keeps track of transactions and database changes
Backups / Snapshots
- Periodic ( Incremental ) copies of database and journal
Checkpoint facility
- Used to make recovery more efficient
DBMS recovery subsystem ( Recovery Manager )
- Allows system to restore the database to a consistent state during a failure
Just having backups is not a solution if the facility to recover ( backup protocol ) does not exist.
## Buffers
The database buffers occupy an area of primary storage from which data is transferred to and from secondary storage.
Only when buffers have been written to secondary storage can any updates be regarded permanent.
Flushing can be triggered by:
- Commits
- Buffer full
## Effects of Failure
- Loss of primary storage ( buffer loss )
- Loss of database on secondary storage
DBMS recovery subsystem uses techniques that minimise effects
## Atomicity and Durability
Recovery manager is responsible for maintaining atomicity and durability of transactions in event of failure.
### Atomicity
All operations of transaction are performed, or none.
- Recovery manager ensures all effects of committed transactions reach the database, and effects of uncommitted transactions are undone or ignored.
### Durability
Effects of committed transactions are permanent
- Effects must survive both loss of RAM and disk storage.
## Recovery Management
### System Failure
- Transaction can commit once writes are made to database buffers.
- Updates made to buffer are not automatically written to secondary storage.
- There may be delay between committing and writing to secondary storage
- If system fails during this delay, recovery manager must ensure updates reach the copy of the database on secondary storage.
- If system failure occurs:
- Database buffers are lost
- Copy of the database on secondary storage may be incorrect.
### Log File ( Journal )
To keep track of database transactions, the DBMS maintains a journal.
Two or three copies of the log file are kept on secondary storage due to the importance in the recovery process.
If the system fails, the log file is examined to see which transactions to redo / which transactions to undo or ignore.
#### Contents of Journal
- Transaction identifier
- Type of log record
- Start, insert, update, delete, abort, commit
- Identifier of data item affected by database action
- Insert, delete, update
- Before Image
- Value of data item before operation of log entry
- After Image
- Value of data item after operation of log entry
- Log management information
- Checkpoint records
##### Data Entries
`Start_transaction( T )` - Records transaction T starts execution
`Write_item( T, X, old_value, new_value )` - Records transaction T changes the value of database item X from the before image to the new image.
`Read_item( T, X )` - Records transaction T reads the value of database item X. Not always logged.
`Commit( T )` - Records transaction T has completed all accesses to the database successfully and its effect can be recorded permanently to the database.
`Checkpoint` - Used to make recovery more efficient. Covered in Part 2.
##### Example 1
![](Pasted%20image%2020240227171626.png)
##### Example 2
Schedule:
![](Pasted%20image%2020240227171700.png)
Log File:
![](Pasted%20image%2020240227171728.png)
### Recovery Rules
- Identify transactions that were committed.
- Undo / Ignore uncommitted transactions, depending on protocol.
- Redo committed transactions.
#### Undoing Transactions
- If transaction crash occurs, recovery manager may undo transactions.
- This is achieved by examining the transaction log and for every write entry, setting the value of item X in the database to the old value.
- Undoing a number of write item operations from one or more transactions from the log must proceed in the reverse order from the order in which the operations appear in the log.
#### Redoing Transactions
- For every write entry in the transaction log, the value of item X in the database is set to the new value.
- Redoing a number of write operations from one or more transactions from the log must proceed in the same order in which the operations were written in the log.

View File

@@ -0,0 +1,13 @@
#BlueJ class context
comment0.params=
comment0.target=int\ getPlayingTime()
comment0.text=\n\ Field\ Accessor\ Start\n
comment1.params=playingTime
comment1.target=void\ setPlayingTime(int)
comment1.text=\n\ Field\ Accessor\ End\n\ \n\ Field\ Mutator\ Start\n
comment2.params=
comment2.target=void\ printDetails()
comment2.text=\n\ Field\ Mutator\ End\n
comment3.params=detailScanner
comment3.target=void\ readItemData(java.util.Scanner)
numComments=4

View File

@@ -0,0 +1,52 @@
/**
* Write a description of class AudioVisual here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
import java.util.ArrayList;
import java.util.NoSuchElementException;
public abstract class AudioVisual extends LibraryItem
{
private int playingTime;
/*
* Field Accessor Start
*/
public int getPlayingTime()
{
return playingTime;
}
/*
* Field Accessor End
*
* Field Mutator Start
*/
public void setPlayingTime( int playingTime )
{
this.playingTime = playingTime;
}
/*
* Field Mutator End
*/
public void printDetails()
{
System.out.println( "Playing Time: " + playingTime );
super.printDetails();
}
public void readItemData( Scanner detailScanner ){
if ( detailScanner != null ) {
this.playingTime = Integer.parseInt( detailScanner.next().trim() );
super.readItemData( detailScanner );
}
}
}

View File

@@ -1,16 +1,14 @@
/** /**
* Subclass of LibraryItem that emulates a Book item in a Library * Subclass of LibraryItem that emulates a Book item.
* *
* @George Wilkinson * @George Wilkinson
* @1.0 * @1.0
*/ */
import java.util.Scanner; import java.util.Scanner;
import java.util.ArrayList;
import java.util.NoSuchElementException;
public class Book extends LibraryItem public class Book extends PrintedItem
{ {
private String author; private String author;
private String isbn; private String isbn;
@@ -21,11 +19,9 @@ public class Book extends LibraryItem
public Book(){} public Book(){}
public void printDetails() { public void printDetails() {
System.out.println("\n==================\n( " + getItemCode() + " )" + " ISBN: " + isbn + " Book " + getTitle() + ", written by " + author + ", published by " + getPublisher() + " has " + getNoOfPages() + " pages .\nIt has been borrowed " + getTimesBorrowed() + " times."); System.out.println( "ISBN: " + isbn +
if( getOnLoan() ) "\nAuthor: " + author );
System.out.println( "The Book is currently on loan, and costs " + getCost() + " pence. "); super.printDetails();
else
System.out.println( "The Book is currently not on loan, and costs " + getCost() + " pence. ");
} }
public void readItemData( Scanner detailScanner ){ public void readItemData( Scanner detailScanner ){

Binary file not shown.

View File

@@ -0,0 +1,17 @@
#BlueJ class context
comment0.params=
comment0.target=CD()
comment0.text=\n\ Constructor\ for\ objects\ of\ class\ CD\n
comment1.params=
comment1.target=java.lang.String\ getArtist()
comment2.params=
comment2.target=int\ noOfTracks()
comment3.params=artist
comment3.target=void\ setArtist(java.lang.String)
comment4.params=noOfTracks
comment4.target=void\ setNoOfTracks(int)
comment5.params=
comment5.target=void\ printDetails()
comment6.params=detailScanner
comment6.target=void\ readItemData(java.util.Scanner)
numComments=7

View File

@@ -0,0 +1,55 @@
/**
* Write a description of class CD here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
public class CD extends AudioVisual
{
private String artist;
private int noOfTracks;
/**
* Constructor for objects of class CD
*/
public CD(){}
public String getArtist()
{
return artist;
}
public int noOfTracks()
{
return noOfTracks;
}
public void setArtist( String artist )
{
this.artist = artist;
}
public void setNoOfTracks( int noOfTracks )
{
this.noOfTracks = noOfTracks;
}
public void printDetails() {
System.out.println( "Artist: " + artist +
"\nTrack Count: " + noOfTracks );
super.printDetails();
}
public void readItemData( Scanner detailScanner ){
if ( detailScanner != null ) {
this.artist = detailScanner.next().trim();
this.noOfTracks = Integer.parseInt( detailScanner.next().trim() );
super.readItemData( detailScanner );
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,13 @@
#BlueJ class context
comment0.params=
comment0.target=DVD()
comment0.text=\n\ Constructor\ for\ objects\ of\ class\ DVD\n
comment1.params=
comment1.target=java.lang.String\ getDirector()
comment2.params=director
comment2.target=void\ setDirector(java.lang.String)
comment3.params=
comment3.target=void\ printDetails()
comment4.params=detailScanner
comment4.target=void\ readItemData(java.util.Scanner)
numComments=5

View File

@@ -0,0 +1,40 @@
/**
* Write a description of class DVD here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
public class DVD extends AudioVisual
{
private String director;
/**
* Constructor for objects of class DVD
*/
public DVD(){}
public String getDirector()
{
return director;
}
public void setDirector( String director )
{
this.director = director;
}
public void printDetails() {
System.out.println( "Director: " + director );
super.printDetails();
}
public void readItemData( Scanner detailScanner ){
if ( detailScanner != null ) {
this.director = detailScanner.next().trim();
super.readItemData( detailScanner );
}
}
}

View File

@@ -5,9 +5,19 @@ comment0.text=\n\ Constructor\ for\ objects\ of\ class\ Library\n
comment1.params=item comment1.params=item
comment1.target=void\ storeItem(LibraryItem) comment1.target=void\ storeItem(LibraryItem)
comment1.text=\n\ Appends\ a\ LibraryItem\ to\ the\ itemList.\n comment1.text=\n\ Appends\ a\ LibraryItem\ to\ the\ itemList.\n
comment2.params= comment2.params=user
comment2.target=void\ printAllItems() comment2.target=void\ storeUser(LibraryUser)
comment2.text=\n\ Prints\ to\ the\ terminal\ all\ items\ in\ the\ itemList\n comment2.text=\n\ Appends\ a\ LibraryUser\ to\ the\ userList.\n
comment3.params= comment3.params=prefix\ length
comment3.target=void\ readItemData() comment3.target=java.lang.String\ generateUserID(java.lang.String,\ int)
numComments=4 comment3.text=\n\ Returns\ a\ random\ unique\ user\ ID\ by\ specifying\ \n\ @prefix\ -\ arbitrary\ alphanumeric\ prefix\n\ @length\ -\ length\ of\ numeric\ ID\n\ \n\ Example\:\ length\ \=\ 6,\ expected\ result\ should\ be\ under\ 999,999\ and\ above\ 99,999.\n\ If\ we\ just\ use\ 10^(length),\ this\ would\ generate\ any\ number\ under\ 1,000,000.\n\ This\ is\ an\ issue\ since\ any\ integers\ below\ 100,000\ can\ be\ used,\ which\ would\ be\ incorrect.\n\ By\ using\ the\ offset\ of\ a\ factor\ of\ 10\ below\ the\ desired\ length\ we\ can\ generate\ between\ 0\ and\ 899,999.\n\ After\ this,\ we\ can\ add\ 100,000\ back\ to\ the\ number\ to\ ensure\ a\ baseline\ length\ is\ maintained.\n\ \n\ Note\:\ I\ am\ aware\ that\ this\ is\ overengineered,\ and\ that\ several\ random\ integers\ of\ amount\ @length\ could\ be\ used,\ \n\ but\ this\ is\ considerably\ more\ efficient\ since\ there\ is\ no\ iteration\ involved\ in\ the\ creation\ of\ the\ ID.\ O(1)\n
comment4.params=
comment4.target=void\ writeUserData()
comment4.text=\n\ A\ method\ to\ output\ all\ user\ data\ to\ a\ file\ using\ a\ fileDialog\ to\ specify\ file\ location.\n\ \n\ Note\:\ Potentially\ could\ implement\ the\ HashSet\ made\ for\ GenerateUserID\ to\ avoid\ unnecessary\ recursion.\n
comment5.params=
comment5.target=void\ printAll()
comment5.text=\n\ Prints\ to\ the\ terminal,\ in\ a\ human-readable\ format,\ all\ items\ in\ the\ itemList\n\ \n\ Contains\ a\ marker\ at\ the\ start\ and\ end\ to\ visualise\ in\ terminal\ output.\n
comment6.params=
comment6.target=void\ readData()
comment6.text=\n\ A\ method\ to\ read\ all\ data\ from\ files\ using\ a\ fileDialog\ to\ specify\ file\ location.\n\ This\ will\ create\ the\ corresponding\ objects\ depending\ on\ flags\ contained\ in\ the\ file\n\ and\ populate\ it's\ fields.\n\ \n\ Default\ flag\ value\:\ "book",\ to\ support\ legacy\ files.\ This\ will\ not\ interfere\ with\ \n\ files\ of\ different\ flag\ orders.\n
numComments=7

View File

@@ -1,22 +1,27 @@
/** /**
* Write a description of class Library here. * Class to create objects of a Library, which can hold and report on assets held within
* *
* @author (your name) * @George Wilkinson
* @version (a version number or a date) * @2.0
*/ */
// Import all required libraries. Not using .* as it is not good practice due to potential conflicts. // Import all required libraries. Not using .* as it is not good practice due to potential conflicts.
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner; import java.util.Scanner;
import java.util.Random;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.awt.FileDialog; import java.awt.FileDialog;
import java.awt.Frame; import java.awt.Frame;
import java.io.PrintWriter;
public class Library public class Library
{ {
private ArrayList<LibraryItem> itemList; // Initialise an ArrayList of name itemList to store LibraryItems private ArrayList<LibraryItem> itemList; // Initialise an ArrayList of name itemList to store Library Items
private ArrayList<LibraryUser> userList; // Initialise an ArrayList of name userList to store Library Users
private HashSet<String> uuidSet; // Initialise a Hash Set of name uuidSet ( unique user identifier ) to store unique user IDs for efficient O(1) searching
/* /*
* Constructor for objects of class Library * Constructor for objects of class Library
@@ -24,6 +29,8 @@ public class Library
public Library() public Library()
{ {
itemList = new ArrayList<LibraryItem>(); itemList = new ArrayList<LibraryItem>();
userList = new ArrayList<LibraryUser>();
uuidSet = new HashSet<String>();
} }
/* /*
@@ -35,17 +42,110 @@ public class Library
} }
/* /*
* Prints to the terminal all items in the itemList * Appends a LibraryUser to the userList.
*/ */
public void printAllItems() public void storeUser( LibraryUser user )
{ {
for( LibraryItem item : itemList ) userList.add( user );
if ( user.getUserID().equals( "unknown" ) )
{ {
item.printDetails(); user.setUserID( generateUserID( "AB-", 6 ) );
} }
} }
public void readItemData() //throws IOException /*
* Returns a random unique user ID by specifying
* @prefix - arbitrary alphanumeric prefix
* @length - length of numeric ID
* and returning a unique user id
* @uuid - a unique string starting with @prefix, and concat. with a random number
*
* Example: length = 6, expected result should be under 999,999 and above 99,999.
* If we just use 10^(length), this would generate any number under 1,000,000.
* This is an issue since any integers below 100,000 can be used, which would be incorrect.
* By using the offset of a factor of 10 below the desired length we can generate between 0 and 899,999.
* After this, we can add 100,000 back to the number to ensure a baseline length is maintained.
*
* Note: I am aware that this is overengineered, and that several random integers of amount @length could be used,
* but this is considerably more efficient since there is no iteration involved in the creation of the ID. O(1)
*/
public String generateUserID( String prefix, int length )
{
Random random = new Random();
final int offset = (int) Math.pow( 10, (length-1) ); // Static integer equal to 10^(length-1) lower than length. This will allow for the factor to be consistent.
int intLength = (int) ( Math.pow( 10, length ) ) - offset ; // Integer equal to 10^(length) minus the offset. This creates a ceiling for the ID range.
if ( uuidSet.size() > ( intLength - 1 ) ) { // No idea why I get an error for equals FIX LATER
System.out.println("Too many user IDs delegated for current range, increasing ID range by a factor of 10");
return generateUserID( prefix, length+1 );
/*
* This is essential for eliminating a stack overflow error when the specified range is full. This would be incorrect to catch.
* By incrementing the length value when the ID range is full, roughly 2.1 billion users can be created without running into an overflow error.
*/
}
String uuid = prefix + ( random.nextInt( intLength ) + offset );
/*
* Sets the uid to the prefix, concat. with a random integer of specified length
* Add the offset to a random number, to create a floor to the ID range.
*/
if ( uuidSet.contains( uuid ) )
{
generateUserID( prefix, length ); // If the ID generated is already contained in the hashset, the method should be called again.
}
uuidSet.add( uuid ); // Add the UUID to the hash set so it cannot be returned from this method more than once.
return uuid;
}
/*
* A method to output all user data to a file using a fileDialog to specify file location.
*
* Note: Potentially could implement the HashSet made for GenerateUserID to avoid unnecessary recursion.
*/
public void writeUserData()
{
try {
Frame frame = null; // Initialise null frame
FileDialog fileBox = new FileDialog( frame, "Save", FileDialog.SAVE ); // Initialise file dialog box to save written data.
fileBox.setVisible( true );
PrintWriter writer = new PrintWriter( new File( fileBox.getDirectory() + fileBox.getFile() ) );
for ( LibraryUser user : userList ){
user.writeData( writer );
}
writer.close();
}
catch( IOException e ) { // Catch any IO Exceptions that may occur from improper file selection.
System.err.println( "Caught IOException: " + e.getMessage() + "\nAn I/O Exception has occurred, please check file is readable and correct format." );
}
}
/*
* Prints to the terminal, in a human-readable format, all items in the itemList
*
* Contains a marker at the start and end to visualise in terminal output.
*/
public void printAll()
{
System.out.println("\n\nStart Detail Print");
for( LibraryItem item : itemList )
{
System.out.println("---------------");
item.printDetails();
}
System.out.println("End Detail Print\n");
}
/*
* A method to read all data from files using a fileDialog to specify file location.
* This will create the corresponding objects depending on flags contained in the file
* and populate it's fields.
*
* Default flag value: "book", to support legacy files. This will not interfere with
* files of different flag orders.
*/
public void readData()
{ {
Frame frame = null; // Initialise a null frame Frame frame = null; // Initialise a null frame
FileDialog fileBox = new FileDialog( frame, "Open", FileDialog.LOAD ); // Initialise filebox with the null frame pointer FileDialog fileBox = new FileDialog( frame, "Open", FileDialog.LOAD ); // Initialise filebox with the null frame pointer
@@ -53,30 +153,33 @@ public class Library
try { try {
Scanner fileScanner = new Scanner( new File( fileBox.getDirectory() + fileBox.getFile() ) ); Scanner fileScanner = new Scanner( new File( fileBox.getDirectory() + fileBox.getFile() ) );
String typeFlag = ""; String typeFlag = "book"; // Set a default flag to support legacy files.
while( fileScanner.hasNextLine() ){ while( fileScanner.hasNextLine() ){
String lineItem = fileScanner.nextLine(); String lineItem = fileScanner.nextLine();
//System.out.println( lineItem );
// Ensure no comments or empty lines are included // Ensure no comments or empty lines are included
if ( lineItem.contains( "//" ) || lineItem.trim().isEmpty() ){} if ( lineItem.contains( "//" ) || lineItem.trim().isEmpty() ){}
// Check current line is a candidate flag // Check current line is a candidate flag
else if ( lineItem.startsWith("[" ) ) { else if ( lineItem.startsWith("[" ) ) {
if ( lineItem.toLowerCase().contains("book") ) {
if ( lineItem.toLowerCase().contains("book") )
typeFlag = "book"; typeFlag = "book";
//System.out.println( "CHANGED FLAG TO READ BOOKS" ); else if ( lineItem.toLowerCase().contains("periodical") )
}
else if ( lineItem.toLowerCase().contains("periodical") ) {
typeFlag = "periodical"; typeFlag = "periodical";
//System.out.println( "CHANGED FLAG TO READ PERIODICALS" ); else if ( lineItem.toLowerCase().contains("cd") )
} typeFlag = "cd";
else if ( lineItem.toLowerCase().contains("dvd") )
typeFlag = "dvd";
else if ( lineItem.toLowerCase().contains("user") )
typeFlag = "user";
else { else {
System.out.println( "Flag detected, but no accepted format...\n Cannot store item in Library. Changing Flag to generic and skipping the following: "); System.out.println( "Flag detected, but no accepted format...\n Cannot store item in Library. Changing Flag to generic and skipping the following: ");
typeFlag = "generic"; typeFlag = "generic";
} }
} }
// Could be a switch case to be more efficient // Could be a switch case to be more efficient
@@ -96,8 +199,29 @@ public class Library
periodical.readItemData( detailScanner ); periodical.readItemData( detailScanner );
storeItem( periodical ); storeItem( periodical );
} }
else if ( typeFlag.equals( "cd" ) ) {
//Process CD Data
Scanner detailScanner = new Scanner ( lineItem ).useDelimiter(",");
LibraryItem cd = new CD();
cd.readItemData( detailScanner );
storeItem( cd );
}
else if ( typeFlag.equals( "dvd" ) ) {
//Process DVD Data
Scanner detailScanner = new Scanner ( lineItem ).useDelimiter(",");
LibraryItem dvd = new DVD();
dvd.readItemData( detailScanner );
storeItem( dvd );
}
else if ( typeFlag.equals( "user" ) ) {
//Process User Data
Scanner detailScanner = new Scanner ( lineItem ).useDelimiter(",");
LibraryUser user = new LibraryUser();
user.readData( detailScanner );
storeUser( user );
}
else if ( typeFlag.equals( "generic" ) ) { else if ( typeFlag.equals( "generic" ) ) {
// Output unaccepted lines // Output unaccepted lines to terminal
System.out.println( lineItem ); System.out.println( lineItem );
} }
} }

View File

@@ -4,34 +4,26 @@ comment0.target=java.lang.String\ getTitle()
comment0.text=\n\ Field\ Accessor\ Start\n comment0.text=\n\ Field\ Accessor\ Start\n
comment1.params= comment1.params=
comment1.target=java.lang.String\ getItemCode() comment1.target=java.lang.String\ getItemCode()
comment10.params=timesBorrowed comment10.params=
comment10.target=void\ setTimesBorrowed(int) comment10.target=void\ printDetails()
comment11.params=onLoan comment10.text=\n\ \ \ \ public\ void\ printDetails()\n\ \ \ \ {\n\ \ \ \ \ \ \ \ System.out.println(\ title\ +\ "\ with\ an\ item\ code\ "\ +\ itemCode\ +\ "\ has\ been\ borrowed\ "\ +\ timesBorrowed\ +\ "\ times.");\n\ \ \ \ \ \ \ \ if(\ onLoan\ )\n\ \ \ \ \ \ \ \ \ \ \ \ System.out.println(\ "This\ item\ is\ at\ present\ on\ loan\ and\ when\ new\ cost\ "\ +\ cost\ +\ "\ pence.\\n"\ );\n\ \ \ \ \ \ \ \ else\ \n\ \ \ \ \ \ \ \ \ \ \ \ System.out.println(\ "This\ item\ is\ at\ present\ not\ on\ loan\ and\ when\ new\ cost\ "\ +\ cost\ +\ "\ pence.\\n"\ );\n\ \ \ \ }\n
comment11.target=void\ setOnLoan(boolean) comment11.params=detailScanner
comment12.params=noOfPages comment11.target=void\ readItemData(java.util.Scanner)
comment12.target=void\ setNoOfPages(int)
comment13.params=publisher
comment13.target=void\ setPublisher(java.lang.String)
comment14.params=
comment14.target=void\ printDetails()
comment14.text=\n\ Field\ Mutator\ End\n
comment15.params=detailScanner
comment15.target=void\ readItemData(java.util.Scanner)
comment2.params= comment2.params=
comment2.target=int\ getCost() comment2.target=int\ getCost()
comment3.params= comment3.params=
comment3.target=int\ getTimesBorrowed() comment3.target=int\ getTimesBorrowed()
comment4.params= comment4.params=
comment4.target=boolean\ getOnLoan() comment4.target=boolean\ getOnLoan()
comment5.params= comment5.params=title
comment5.target=int\ getNoOfPages() comment5.target=void\ setTitle(java.lang.String)
comment6.params= comment5.text=\n\ Field\ Accessor\ End\n\ \n\ Field\ Mutator\ Start\n
comment6.target=java.lang.String\ getPublisher() comment6.params=itemCode
comment7.params=title comment6.target=void\ setItemCode(java.lang.String)
comment7.target=void\ setTitle(java.lang.String) comment7.params=cost
comment7.text=\n\ Field\ Accessor\ End\n\ \n\ Field\ Mutator\ Start\n comment7.target=void\ setCost(int)
comment8.params=itemCode comment8.params=timesBorrowed
comment8.target=void\ setItemCode(java.lang.String) comment8.target=void\ setTimesBorrowed(int)
comment9.params=cost comment9.params=onLoan
comment9.target=void\ setCost(int) comment9.target=void\ setOnLoan(boolean)
numComments=16 numComments=12

View File

@@ -1,9 +1,9 @@
/** /**
* Emulates an Item in a Library ( * Superclass of items / assets stored in a Library.
* *
* @author (your name) * @George Wilkinson
* @version (a version number or a date) * @2.1
*/ */
import java.util.Scanner; import java.util.Scanner;
@@ -18,8 +18,6 @@ public abstract class LibraryItem
private int cost; private int cost;
private int timesBorrowed; private int timesBorrowed;
private boolean onLoan; private boolean onLoan;
private int noOfPages;
private String publisher;
/* /*
* Field Accessor Start * Field Accessor Start
@@ -48,17 +46,7 @@ public abstract class LibraryItem
{ {
return onLoan; return onLoan;
} }
public int getNoOfPages()
{
return noOfPages;
}
public String getPublisher()
{
return publisher;
}
/* /*
* Field Accessor End * Field Accessor End
* *
@@ -90,21 +78,13 @@ public abstract class LibraryItem
this.onLoan = onLoan; this.onLoan = onLoan;
} }
public void setNoOfPages( int noOfPages )
{
this.noOfPages = noOfPages;
}
public void setPublisher( String publisher )
{
this.publisher = publisher;
}
/* /*
* Field Mutator End * Field Mutator End
*/ */
// Output to console the details of the fields in a human-readable format. // Output to console the details of the fields in a human-readable format.
/*
public void printDetails() public void printDetails()
{ {
System.out.println( title + " with an item code " + itemCode + " has been borrowed " + timesBorrowed + " times."); System.out.println( title + " with an item code " + itemCode + " has been borrowed " + timesBorrowed + " times.");
@@ -113,12 +93,23 @@ public abstract class LibraryItem
else else
System.out.println( "This item is at present not on loan and when new cost " + cost + " pence.\n" ); System.out.println( "This item is at present not on loan and when new cost " + cost + " pence.\n" );
} }
*/
public void readItemData( Scanner detailScanner ) { public void printDetails()
{
System.out.println("Item Code: " + itemCode +
"\nTitle: " + title +
"\nCost: £" + ( ( float )( cost ) )/100 +
"\nBorrowed " + getTimesBorrowed() + " times." );
if( getOnLoan() )
System.out.println( "On Loan");
else
System.out.println( "Available to Loan");
}
public void readItemData( Scanner detailScanner ) {
if ( detailScanner != null ) { if ( detailScanner != null ) {
this.noOfPages = Integer.parseInt( detailScanner.next().trim() );
this.publisher = detailScanner.next().trim();
this.title = detailScanner.next().trim(); this.title = detailScanner.next().trim();
this.itemCode = detailScanner.next().trim(); this.itemCode = detailScanner.next().trim();
this.cost = Integer.parseInt( detailScanner.next().trim() ); this.cost = Integer.parseInt( detailScanner.next().trim() );

View File

@@ -0,0 +1,31 @@
#BlueJ class context
comment0.params=
comment0.target=LibraryUser()
comment0.text=\n\ Constructor\ for\ objects\ of\ class\ LibraryUser\n
comment1.params=
comment1.target=java.lang.String\ getUserID()
comment10.params=title
comment10.target=void\ setTitle(java.lang.String)
comment11.params=writer
comment11.target=void\ writeData(java.io.PrintWriter)
comment12.params=
comment12.target=void\ printDetails()
comment13.params=detailScanner
comment13.target=void\ readData(java.util.Scanner)
comment2.params=
comment2.target=java.lang.String\ getSurname()
comment3.params=
comment3.target=java.lang.String\ getFirstName()
comment4.params=
comment4.target=java.lang.String\ getOtherInitials()
comment5.params=
comment5.target=java.lang.String\ getTitle()
comment6.params=userID
comment6.target=void\ setUserID(java.lang.String)
comment7.params=surname
comment7.target=void\ setSurname(java.lang.String)
comment8.params=firstName
comment8.target=void\ setFirstName(java.lang.String)
comment9.params=otherInitials
comment9.target=void\ setOtherInitials(java.lang.String)
numComments=14

View File

@@ -0,0 +1,87 @@
/**
* Write a description of class LibraryUser here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
import java.io.PrintWriter;
public class LibraryUser
{
// instance variables - replace the example below with your own
private String userID, surname, firstName, otherInitials, title;
/**
* Constructor for objects of class LibraryUser
*/
public LibraryUser(){}
public String getUserID(){
return userID;
}
public String getSurname(){
return surname;
}
public String getFirstName(){
return firstName;
}
public String getOtherInitials(){
return otherInitials;
}
public String getTitle(){
return title;
}
public void setUserID( String userID ){
this.userID = userID;
}
public void setSurname( String surname ){
this.surname = surname;
}
public void setFirstName( String firstName ){
this.firstName = firstName;
}
public void setOtherInitials( String otherInitials ){
this.otherInitials = otherInitials;
}
public void setTitle( String title ){
this.title = title;
}
public void writeData( PrintWriter writer )
{
writer.print(userID + ", " + surname + ", " + firstName + ", " + otherInitials + ", " + title + "\n");
writer.flush();
}
public void printDetails()
{
System.out.println( "ID: " + userID +
"\nName: " + title + " " + firstName + " " + otherInitials + " " + surname );
}
public void readData( Scanner detailScanner )
{
if ( detailScanner != null ) {
this.userID = detailScanner.next().trim();
this.surname = detailScanner.next().trim();
this.firstName = detailScanner.next().trim();
this.otherInitials = detailScanner.next().trim();
this.title = detailScanner.next().trim();
}
}
}

View File

@@ -1,24 +1,22 @@
/** /**
* Write a description of class Periodical here. * Subclass of LibraryItem to create a periodical ( e.g. newspaper, tabloid ).
* *
* @author (your name) * @George Wilkinson
* @version (a version number or a date) * @1.0
*/ */
import java.util.Scanner; import java.util.Scanner;
public class Periodical extends LibraryItem
public class Periodical extends PrintedItem
{ {
private String publicationDate; private String publicationDate;
public Periodical(){} public Periodical(){}
public void printDetails() { public void printDetails() {
System.out.println("\n==================\n( " + getItemCode() + " )" + " Publication Date: " + publicationDate + " Periodical " + getTitle() + ", published by " + getPublisher() + " has " + getNoOfPages() + " pages .\nIt has been borrowed " + getTimesBorrowed() + " times."); System.out.println( "Publication Date: " + publicationDate );
if( getOnLoan() ) super.printDetails();
System.out.println( "The Periodical is currently on loan, and costs " + getCost() + " pence. ");
else
System.out.println( "The Periodical is currently not on loan, and costs " + getCost() + " pence. ");
} }
public void readItemData( Scanner detailScanner ){ public void readItemData( Scanner detailScanner ){

View File

@@ -0,0 +1,17 @@
#BlueJ class context
comment0.params=
comment0.target=int\ getNoOfPages()
comment0.text=\n\ Field\ Accessor\ Start\n
comment1.params=
comment1.target=java.lang.String\ getPublisher()
comment2.params=noOfPages
comment2.target=void\ setNoOfPages(int)
comment2.text=\n\ Field\ Accessor\ End\n\ \n\ Field\ Mutator\ Start\n
comment3.params=publisher
comment3.target=void\ setPublisher(java.lang.String)
comment4.params=
comment4.target=void\ printDetails()
comment4.text=\n\ Field\ Mutator\ End\n
comment5.params=detailScanner
comment5.target=void\ readItemData(java.util.Scanner)
numComments=6

View File

@@ -0,0 +1,64 @@
/**
* Write a description of class PrintedItem here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
import java.util.ArrayList;
import java.util.NoSuchElementException;
public abstract class PrintedItem extends LibraryItem
{
private int noOfPages;
private String publisher;
/*
* Field Accessor Start
*/
public int getNoOfPages()
{
return noOfPages;
}
public String getPublisher()
{
return publisher;
}
/*
* Field Accessor End
*
* Field Mutator Start
*/
public void setNoOfPages( int noOfPages )
{
this.noOfPages = noOfPages;
}
public void setPublisher( String publisher )
{
this.publisher = publisher;
}
/*
* Field Mutator End
*/
public void printDetails()
{
System.out.println("Page Count: " + noOfPages +
"\nPublisher: " + publisher);
super.printDetails();
}
public void readItemData( Scanner detailScanner ){
if ( detailScanner != null ) {
this.noOfPages = Integer.parseInt( detailScanner.next().trim() );
this.publisher = detailScanner.next().trim();
super.readItemData( detailScanner );
}
}
}

View File

@@ -0,0 +1,43 @@
// this is a comment, any lines that start with //
// (and blank lines) should be ignored
[Book data]
// data is author, isbn, noOfPages, publisher, title, itemCode, cost, timesBorrowed, onLoan
Barnes and Kolling, 9780131976290,480, Pearson, Objects First with Java, LM002411,3989,781,true
Aho Sethi and Ullman, 9780201101942,795, Addison-Wesley, Compilers: Principles Techniques and Tools, LM002711,599,500,FALSE
Harvey Paul and Jeffrey, 9780130622211,1568, Prentice Hall, C# How to Program, LM002876,4599,45,TRUE
Muster, 9780072193145,1011, McGraw-Hill, Unix Made Easy: The Basics and Beyond (Made Easy), LM002468,6395,678,TRUE
Thomee, 9783540331216,370, Springer Verlag, Galerkin Finite Element Methods for Parabolic Problems, LM002153,4554,543,FALSE
[periodical data]
// data is publicationDate, noOfPages, publisher, title, itemCode, cost, timesBorrowed, onLoan
25-03-20,70, News International, The Times, LM005447,80,250000,FALSE
26-03-20,70, News International, The Times, LM005002,80,560562,false
26-04-20, 70, Associated Newspapers, Daily Mail, LM005177,75,478908,false
[CD data]
// data is artist, noOfTracks, playingTime, title, itemCode, cost, timesBorrowed, onLoan
James Blunt,15,68, Back to Bedlam, LM003604,498,234,true
Duffy,10,73, Rockferry, LM003553,898,90,false
Adele,12,19,75, LM003580,798,87,FALSE
Robert Plant and Alison Krauss,13,72, Raising Sand, LM003750,898,89,tRUE
Goldfrapp,10,72, Seventh Tree, LM003873,1299,9876,true
Amy Winehouse,11,70, Back To Black, LM003698,698,8765,false
Jack Johnson,15,67, Sleep Through The Static, LM003773,898,54,True
Mark Ronson,14,74, Version, LM003365,698,56,true
Radiohead,10,75, In Rainbows , LM003771,798,6543,FALSE
Nick Cave,11,68, Dig!!! Lazarus Dig!!!, LM003751,1199,90,False
Nickelback,11,72, All the Right Reasons, LM003915,598,32,true
[DVD data]
// data is director, playingTime, title, itemCode, cost, timesBorrowed, onLoan
Chris Miller,92, Shrek The Third, LM004314,1026,900,TRUE
Robert Zemeckis,114, Beowulf , LM004079,900,87,FALSE
Phyllida Lloyd,118, Mamma Mia, LM004984,798,566,true
Joe Wright,130, Atonement, LM004720,1293,66,true
Andrew Adamson,125, The Chronicles of Narnia: Prince Caspian, LM004178,345,45,FALSE

View File

@@ -0,0 +1,48 @@
// this is a comment, any lines that start with //
// (and blank lines) should be ignored
[Book data]
// data is author, isbn, noOfPages, publisher, title, itemCode, cost, timesBorrowed, onLoan
Barnes and Kolling, 9780131976290,480, Pearson, Objects First with Java, LM002411,3989,781,true
Aho Sethi and Ullman, 9780201101942,795, Addison-Wesley, Compilers: Principles Techniques and Tools, LM002711,599,890,FALSE
Harvey Paul and Jeffrey, 9780130622211,1568, Prentice Hall, C# How to Program, LM002876,4599,45,TRUE
Muster, 9780072193145,1011, McGraw-Hill, Unix Made Easy: The Basics and Beyond (Made Easy), LM002468,6395,8765,TRUE
Thomee, 9783540331216,370, Springer Verlag, Galerkin Finite Element Methods for Parabolic Problems, LM002153,4554,780,FALSE
[CD data]
// data is artist, noOfTracks, playingTime, title, itemCode, cost, timesBorrowed, onLoan
James Blunt,15,68, Back to Bedlam, LM003604,498,234,true
Duffy,10,73, Rockferry, LM003553,898,90,false
Adele,12,19,75, LM003580,798,87,FALSE
Robert Plant and Alison Krauss,13,72, Raising Sand, LM003750,898,89,tRUE
Goldfrapp,10,72, Seventh Tree, LM003873,1299,9876,true
Amy Winehouse,11,70, Back To Black, LM003698,698,8765,false
Jack Johnson,15,67, Sleep Through The Static, LM003773,898,54,True
Mark Ronson,14,74, Version, LM003365,698,56,true
Radiohead,10,75, In Rainbows , LM003771,798,6543,FALSE
Nick Cave,11,68, Dig!!! Lazarus Dig!!!, LM003751,1199,90,False
Nickelback,11,72, All the Right Reasons, LM003915,598,32,true
[DVD data]
// data is director, playingTime, title, itemCode, cost, timesBorrowed, onLoan
Chris Miller,92, Shrek The Third, LM004314,1026,900,TRUE
Robert Zemeckis,114, Beowulf , LM004079,900,87,FALSE
Phyllida Lloyd,118, Mamma Mia, LM004984,798,566,true
Joe Wright,130, Atonement, LM004720,1293,66,true
Andrew Adamson,125, The Chronicles of Narnia: Prince Caspian, LM004178,345,45,FALSE
[periodical data]
// data is publicationDate, noOfPages, publisher, title, itemCode, cost, timesBorrowed, onLoan
25-03-08,70, News International, The Times, LM005447,80,0,FALSE
26-03-08,70, News International, The Times, LM005002,80,0,false
26-03-08,60, Associated Newspapers, Daily Mail, LM005177,40,0,false
[Library User Data]
// data is userID, surname, firstName, otherInitials, title
unknown, Newton, David, E, Dr
unknown, Gregson, Brian, R T, Mr
unknown, Evans, David, , Dr
unknown, Smith, Sara, C, Ms

View File

@@ -0,0 +1,12 @@
// this is a comment, any lines that start with //
// (and blank lines) should be ignored
// New user data
// data is userID, surname, firstName, otherInitials, title
[Library User Data]
unknown, Newton, David, E, Dr
unknown, Gregson, Brian, R T, Mr
unknown, Evans, David, , Dr
unknown, Smith, Sara, C, Ms

View File

@@ -0,0 +1,4 @@
unknown, Newton, David, E, Dr
unknown, Gregson, Brian, R T, Mr
unknown, Evans, David, , Dr
unknown, Smith, Sara, C, Ms

View File

@@ -0,0 +1,183 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.8.0_392) on Thu Feb 29 11:54:14 GMT 2024 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>
Book
</TITLE>
<META NAME="date" CONTENT="2024-02-29">
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Book";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
Class Book</H2>
<PRE>
java.lang.Object
<IMG SRC="./resources/inherit.gif" ALT="extended by ">LibraryItem
<IMG SRC="./resources/inherit.gif" ALT="extended by ">PrintedItem
<IMG SRC="./resources/inherit.gif" ALT="extended by "><B>Book</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <B>Book</B><DT>extends PrintedItem</DL>
</PRE>
<P>
<HR>
<P>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="Book.html#Book()">Book</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructor for objects of class Book</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="Book.html#printDetails()">printDetails</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="Book.html#readItemData(java.util.Scanner)">readItemData</A></B>(java.util.Scanner&nbsp;detailScanner)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_PrintedItem"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class PrintedItem</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>getNoOfPages, getPublisher, setNoOfPages, setPublisher</CODE></TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_LibraryItem"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class LibraryItem</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>getCost, getItemCode, getOnLoan, getTimesBorrowed, getTitle, setCost, setItemCode, setOnLoan, setTimesBorrowed, setTitle</CODE></TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="Book()"><!-- --></A><H3>
Book</H3>
<PRE>
public <B>Book</B>()</PRE>
<DL>
<DD>Constructor for objects of class Book
<P>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="printDetails()"><!-- --></A><H3>
printDetails</H3>
<PRE>
public void <B>printDetails</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Overrides:</B><DD><CODE>printDetails</CODE> in class <CODE>LibraryItem</CODE></DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="readItemData(java.util.Scanner)"><!-- --></A><H3>
readItemData</H3>
<PRE>
public void <B>readItemData</B>(java.util.Scanner&nbsp;detailScanner)</PRE>
<DL>
<DD><DL>
<DT><B>Overrides:</B><DD><CODE>readItemData</CODE> in class <CODE>PrintedItem</CODE></DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<HR>
</BODY>
</HTML>

View File

@@ -2,13 +2,13 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <HEAD>
<!-- Generated by javadoc (build 1.8.0_392) on Fri Feb 16 14:05:04 GMT 2024 --> <!-- Generated by javadoc (build 1.8.0_392) on Thu Feb 29 11:54:14 GMT 2024 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE> <TITLE>
All Classes All Classes
</TITLE> </TITLE>
<META NAME="date" CONTENT="2024-02-16"> <META NAME="date" CONTENT="2024-02-29">
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
@@ -22,7 +22,7 @@ All Classes
<TABLE BORDER="0" WIDTH="100%" SUMMARY=""> <TABLE BORDER="0" WIDTH="100%" SUMMARY="">
<TR> <TR>
<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="LibraryItem.html" title="class in &lt;Unnamed&gt;" target="classFrame">LibraryItem</A> <TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="Book.html" title="class in &lt;Unnamed&gt;" target="classFrame">Book</A>
<BR> <BR>
</FONT></TD> </FONT></TD>
</TR> </TR>

View File

@@ -2,13 +2,13 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <HEAD>
<!-- Generated by javadoc (build 1.8.0_392) on Fri Feb 16 14:05:04 GMT 2024 --> <!-- Generated by javadoc (build 1.8.0_392) on Thu Feb 29 11:54:14 GMT 2024 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE> <TITLE>
All Classes All Classes
</TITLE> </TITLE>
<META NAME="date" CONTENT="2024-02-16"> <META NAME="date" CONTENT="2024-02-29">
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
@@ -22,7 +22,7 @@ All Classes
<TABLE BORDER="0" WIDTH="100%" SUMMARY=""> <TABLE BORDER="0" WIDTH="100%" SUMMARY="">
<TR> <TR>
<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="LibraryItem.html" title="class in &lt;Unnamed&gt;">LibraryItem</A> <TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="Book.html" title="class in &lt;Unnamed&gt;">Book</A>
<BR> <BR>
</FONT></TD> </FONT></TD>
</TR> </TR>

View File

@@ -2,13 +2,13 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <HEAD>
<!-- Generated by javadoc (build 1.8.0_392) on Fri Feb 16 14:05:04 GMT 2024 --> <!-- Generated by javadoc (build 1.8.0_392) on Thu Feb 29 11:54:14 GMT 2024 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE> <TITLE>
Constant Field Values Constant Field Values
</TITLE> </TITLE>
<META NAME="date" CONTENT="2024-02-16"> <META NAME="date" CONTENT="2024-02-29">
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

View File

@@ -2,7 +2,7 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <HEAD>
<!-- Generated by javadoc on Fri Feb 16 14:05:04 GMT 2024--> <!-- Generated by javadoc on Thu Feb 29 11:54:14 GMT 2024-->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE> <TITLE>
Generated Documentation (Untitled) Generated Documentation (Untitled)
@@ -23,7 +23,7 @@ Generated Documentation (Untitled)
</HEAD> </HEAD>
<FRAMESET cols="20%,80%" title="" onLoad="top.loadFrames()"> <FRAMESET cols="20%,80%" title="" onLoad="top.loadFrames()">
<FRAME src="allclasses-frame.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)"> <FRAME src="allclasses-frame.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)">
<FRAME src="LibraryItem.html" name="classFrame" title="Package, class and interface descriptions" scrolling="yes"> <FRAME src="Book.html" name="classFrame" title="Package, class and interface descriptions" scrolling="yes">
<NOFRAMES> <NOFRAMES>
<H2> <H2>
Frame Alert</H2> Frame Alert</H2>
@@ -31,7 +31,7 @@ Frame Alert</H2>
<P> <P>
This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
<BR> <BR>
Link to<A HREF="LibraryItem.html">Non-frame version.</A> Link to<A HREF="Book.html">Non-frame version.</A>
</NOFRAMES> </NOFRAMES>
</FRAMESET> </FRAMESET>
</HTML> </HTML>

View File

@@ -23,13 +23,13 @@ UTF-8
/usr/share/bluej/bjdoclet.jar /usr/share/bluej/bjdoclet.jar
-doclet -doclet
bluej.doclet.doclets.formats.html.HtmlDoclet bluej.doclet.doclets.formats.html.HtmlDoclet
/home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/LibraryItem.java /home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/Book.java
<---- end of javadoc command ----> <---- end of javadoc command ---->
Loading source file /home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/LibraryItem.java... Loading source file /home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/Book.java...
Constructing Javadoc information... Constructing Javadoc information...
Standard Doclet version 1.8.0_392 Standard Doclet version 1.8.0_392
Building tree for all the packages and classes... Building tree for all the packages and classes...
Generating /home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/doc/LibraryItem.html... Generating /home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/doc/Book.html...
Generating /home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/doc/package-frame.html... Generating /home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/doc/package-frame.html...
Generating /home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/doc/package-summary.html... Generating /home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/doc/package-summary.html...
Generating /home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/doc/constant-values.html... Generating /home/boris/OneDrive/Computer Science Year 1/Semester 2/Programming 2/Project/Part 2/doc/constant-values.html...

View File

@@ -2,13 +2,13 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <HEAD>
<!-- Generated by javadoc (build 1.8.0_392) on Fri Feb 16 14:05:04 GMT 2024 --> <!-- Generated by javadoc (build 1.8.0_392) on Thu Feb 29 11:54:14 GMT 2024 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE> <TITLE>
&lt;Unnamed&gt; &lt;Unnamed&gt;
</TITLE> </TITLE>
<META NAME="date" CONTENT="2024-02-16"> <META NAME="date" CONTENT="2024-02-29">
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
@@ -24,7 +24,7 @@
Classes</FONT>&nbsp; Classes</FONT>&nbsp;
<FONT CLASS="FrameItemFont"> <FONT CLASS="FrameItemFont">
<BR> <BR>
<A HREF="LibraryItem.html" title="class in &lt;Unnamed&gt;" target="classFrame">LibraryItem</A></FONT></TD> <A HREF="Book.html" title="class in &lt;Unnamed&gt;" target="classFrame">Book</A></FONT></TD>
</TR> </TR>
</TABLE> </TABLE>

View File

@@ -2,13 +2,13 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <HEAD>
<!-- Generated by javadoc (build 1.8.0_392) on Fri Feb 16 14:05:04 GMT 2024 --> <!-- Generated by javadoc (build 1.8.0_392) on Thu Feb 29 11:54:14 GMT 2024 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE> <TITLE>
</TITLE> </TITLE>
<META NAME="date" CONTENT="2024-02-16"> <META NAME="date" CONTENT="2024-02-29">
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
@@ -29,7 +29,7 @@ Package &lt;Unnamed&gt;
<B>Class Summary</B></FONT></TH> <B>Class Summary</B></FONT></TH>
</TR> </TR>
<TR BGCOLOR="white" CLASS="TableRowColor"> <TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="LibraryItem.html" title="class in &lt;Unnamed&gt;">LibraryItem</A></B></TD> <TD WIDTH="15%"><B><A HREF="Book.html" title="class in &lt;Unnamed&gt;">Book</A></B></TD>
<TD>&nbsp;</TD> <TD>&nbsp;</TD>
</TR> </TR>
</TABLE> </TABLE>

View File

@@ -8,66 +8,140 @@ dependency2.type=UsesDependency
dependency3.from=Library dependency3.from=Library
dependency3.to=LibraryItem dependency3.to=LibraryItem
dependency3.type=UsesDependency dependency3.type=UsesDependency
dependency4.from=Library
dependency4.to=CD
dependency4.type=UsesDependency
dependency5.from=Library
dependency5.to=DVD
dependency5.type=UsesDependency
dependency6.from=Library
dependency6.to=LibraryUser
dependency6.type=UsesDependency
objectbench.height=76 objectbench.height=76
objectbench.width=1900 objectbench.width=940
package.editor.height=874 package.editor.height=874
package.editor.width=1774 package.editor.width=814
package.editor.x=0 package.editor.x=0
package.editor.y=31 package.editor.y=31
package.numDependencies=3 package.numDependencies=6
package.numTargets=4 package.numTargets=9
package.showExtends=true package.showExtends=true
package.showUses=true package.showUses=true
project.charset=UTF-8 project.charset=UTF-8
target1.editor.height=700 target1.editor.height=700
target1.editor.width=900 target1.editor.width=900
target1.editor.x=40 target1.editor.x=1017
target1.editor.y=52 target1.editor.y=76
target1.height=60 target1.height=50
target1.name=LibraryItem target1.name=PrintedItem
target1.naviview.expanded=true target1.naviview.expanded=true
target1.showInterface=false target1.showInterface=false
target1.type=AbstractTarget target1.type=AbstractTarget
target1.typeParameters= target1.typeParameters=
target1.width=120 target1.width=110
target1.x=160 target1.x=350
target1.y=80 target1.y=220
target2.editor.height=700 target2.editor.height=786
target2.editor.width=1619 target2.editor.width=960
target2.editor.x=60 target2.editor.x=34
target2.editor.y=71 target2.editor.y=174
target2.height=50 target2.height=50
target2.name=Periodical target2.name=CD
target2.naviview.expanded=true target2.naviview.expanded=true
target2.showInterface=false target2.showInterface=false
target2.type=ClassTarget target2.type=ClassTarget
target2.typeParameters= target2.typeParameters=
target2.width=90 target2.width=80
target2.x=30 target2.x=580
target2.y=260 target2.y=320
target3.editor.height=700 target3.editor.height=700
target3.editor.width=1734 target3.editor.width=900
target3.editor.x=60 target3.editor.x=557
target3.editor.y=71 target3.editor.y=177
target3.height=50 target3.height=60
target3.name=Book target3.name=LibraryItem
target3.naviview.expanded=true target3.naviview.expanded=true
target3.showInterface=false target3.showInterface=false
target3.type=ClassTarget target3.type=AbstractTarget
target3.typeParameters= target3.typeParameters=
target3.width=80 target3.width=120
target3.x=330 target3.x=470
target3.y=260 target3.y=90
target4.editor.height=1049 target4.editor.height=1049
target4.editor.width=1920 target4.editor.width=1920
target4.editor.x=0 target4.editor.x=0
target4.editor.y=31 target4.editor.y=31
target4.height=50 target4.height=50
target4.name=Library target4.name=DVD
target4.naviview.expanded=true target4.naviview.expanded=true
target4.showInterface=false target4.showInterface=false
target4.type=ClassTarget target4.type=ClassTarget
target4.typeParameters= target4.typeParameters=
target4.width=100 target4.width=80
target4.x=170 target4.x=690
target4.y=210 target4.y=360
target5.editor.height=700
target5.editor.width=1619
target5.editor.x=192
target5.editor.y=267
target5.height=50
target5.name=Periodical
target5.naviview.expanded=true
target5.showInterface=false
target5.type=ClassTarget
target5.typeParameters=
target5.width=90
target5.x=280
target5.y=360
target6.editor.height=700
target6.editor.width=900
target6.editor.x=55
target6.editor.y=274
target6.height=50
target6.name=LibraryUser
target6.naviview.expanded=true
target6.showInterface=false
target6.type=ClassTarget
target6.typeParameters=
target6.width=110
target6.x=320
target6.y=150
target7.editor.height=1049
target7.editor.width=1920
target7.editor.x=0
target7.editor.y=31
target7.height=50
target7.name=Book
target7.naviview.expanded=true
target7.showInterface=false
target7.type=ClassTarget
target7.typeParameters=
target7.width=80
target7.x=400
target7.y=320
target8.editor.height=1049
target8.editor.width=1920
target8.editor.x=0
target8.editor.y=31
target8.height=50
target8.name=Library
target8.naviview.expanded=true
target8.showInterface=false
target8.type=ClassTarget
target8.typeParameters=
target8.width=100
target8.x=480
target8.y=220
target9.editor.height=700
target9.editor.width=900
target9.editor.x=960
target9.editor.y=146
target9.height=50
target9.name=AudioVisual
target9.naviview.expanded=true
target9.showInterface=false
target9.type=AbstractTarget
target9.typeParameters=
target9.width=110
target9.x=600
target9.y=220

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB