vault backup: 2024-09-05 17:56:43

This commit is contained in:
2024-09-05 17:56:43 +01:00
parent 73d081e6b1
commit f92e45c2bf
100 changed files with 16047 additions and 16337 deletions

View File

@@ -0,0 +1,121 @@
/**
* Class LibraryUser to create a user of a library.
*
* @George Wilkinson
* @2.3
*/
import java.util.Scanner;
import java.io.PrintWriter;
public class LibraryUser
{
// instance variables
private String userID, surname, firstName, otherInitials, title;
/**
* Constructor for objects of class LibraryUser.
*/
public LibraryUser(){}
/*
* Accessor start - return values of corresponding variables.
*/
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;
}
/*
* Accessor End
* Mutator Start - Set value of corresponding variables
*/
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;
}
/*
* Mutator End
*/
/**
* Forms field variables in a desired format, prints
* to the PrintWriter, and flush to the file.
* Takes Parameter
* PrintWriter @writer
*/
public void writeData( PrintWriter writer )
{
writer.print(userID + ", " + surname + ", " + firstName + ", " + otherInitials + ", " + title + "\n");
writer.flush();
}
/*
* Print to terminal all relevant fields.
*/
public void printDetails()
{
System.out.println( "ID: " + userID +
"\nName: " + title + " " + firstName + " " + otherInitials + " " + surname );
}
/**
* Populate the fields with details from the scanner
* Takes Parameters
* Scanner @detailScanner
*/
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();
}
}
}