vault backup: 2024-03-05 13:01:43
This commit is contained in:
87
Semester 2/Programming 2/Project/Part 2/LibraryUser.java
Normal file
87
Semester 2/Programming 2/Project/Part 2/LibraryUser.java
Normal 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user