Created
January 31, 2014 11:51
-
-
Save timxor/8730694 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lab1; | |
public class Student { | |
// Private variables | |
private final String firstName, lastName; | |
private String username; | |
private final int id; | |
private final boolean isFulltime; | |
// End private varibales | |
// Default constructor | |
public Student(String firstName, String lastName, int id, boolean isFulltime) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
this.id = id; | |
this.isFulltime = isFulltime; | |
generateUsername name = new generateUsername(); | |
this.username = name; | |
} | |
// Second constructor | |
public Student(String firstName, String lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
id = 0; | |
isFulltime = true; | |
} | |
// Method | |
private void generateUsername(String username) { | |
String temp = firstName.substring(0, 1) + lastName.substring(0, 6); | |
username = temp.toLowerCase(); | |
this.username = username; | |
} | |
// Getter for firstName | |
public String getFirstName() { | |
return firstName; | |
} | |
// Getter for lastName | |
public String getLastName() { | |
return lastName; | |
} | |
// Getter for id | |
public int getId() { | |
return id; | |
} | |
// Getter for isFulltime | |
public boolean getIsFulltime() { | |
return isFulltime; | |
} | |
// Getter for username | |
public String getUserName() { | |
return username; | |
} | |
// Setter for firstName | |
public void setFirstName(String fname) { | |
fname = firstName; | |
} | |
// Setter for lastName | |
public void setLastName(String lname) { | |
lname = lastName; | |
} | |
// Setter for id | |
public void setId(int sid) { | |
sid = id; | |
} | |
// Getter for isFulltime | |
public void setIsFulltime(boolean iFulltime) { | |
iFulltime = isFulltime; | |
} | |
// Setter for username | |
public void setUserName(String un) { | |
un = username; | |
} | |
public void toStirng() { | |
System.out.println("Student firstName is: " + firstName); | |
System.out.println("Student lastName is: " + lastName); | |
System.out.println("Student id is: " + id); | |
System.out.println("Student username is: " + username); | |
} | |
public static void main(String args[]) { | |
String[] Student = new String[ 5 ]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very pretty