< accessLevelModifier > class < className >{
< code goes here >
}
public class UMBCer{
}
public class UMBCer{
private String firstName;
private String lastName;
private String email;
private String id;
}
public class UBMCer{
private String firstName;
private String lastName;
private String email;
private String id;
...
public void printFullName(){
System.out.println(firstName + " " + lastName);
}
...
}
public class UBMCer{
private String firstName;
private String lastName;
private String email;
private String id;
...
public String getFullName(){
return firstName + " " + lastName;
}
...
}
public class UBMCer{
private String firstName;
private String lastName;
private String email;
private String id;
...
public boolean setEmail(String email){
if(email.endsWith("@umbc.edu"))
{
this.email = email;
return true;
}
return false;
}
...
}
import java.util.Random;
public class UMBCer{
private String firstName;
private String lastName;
private String email;
private String id;
public UMBCer(String firstName, String lastName)
{
this.firstName = firstName;
this.lastName = lastName;
this.email = firstName + "." + lastName + "@umbc.edu";
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Random rnd = new Random();
this.id = alphabet.charAt(rnd.nextInt(alphabet.length())) + "" +
alphabet.charAt(rnd.nextInt(alphabet.length())) +
String.valueOf(rnd.nextInt(9) + 1) + String.valueOf(rnd.nextInt(9) + 1) +
String.valueOf(rnd.nextInt(9) + 1) + String.valueOf(rnd.nextInt(9) + 1);
}
...
}
public class UMBCer{
private String firstName;
private String lastName;
private String email;
private String id;
public boolean equals(Object other)
{
if(!(other instanceof UMBCer) || other == null)
{
return false;
}
UMBCer otherUMBCer = (UMBCer)other;
return this.firstName.equals(otherUMBCer.firstName) &&
this.lastName.equals(otherUMBCer.lastName) &&
this.email.equals(otherUMBCer.email) &&
this.id.equals(otherUMBCer.id);
}
}
public class UMBCer{
private String firstName;
private String lastName;
private String email;
private String id;
public String toString(){
return "UMBCer " + id + ": " + firstName + " " + lastName;
}
}
public class UMBCer{
private String firstName;
private String lastName;
private String email;
private String id;
public void setName(String firstName){
this.firstName = firstName;
}
public boolean setName(String lastName){
this.lastName = lastName;
}
import java.util.GregorianCalendar
public class UMBCer{
private String firstName;
private String lastName;
private String email;
private String id;
private GregorianCalendar birthday;
public void setBirthday(GegorianCalendar date){
this.birthday = (GregorianCalendar)date.clone();
}
public boolean setBirthday(int month, int day, int year){
this.birthday = new GegorianCalendar(year,month,day);
}
import java.util.GregorianCalendar
public class UMBCer{
private String firstName;
private String lastName;
private String email;
private String id;
private GregorianCalendar birthday;
public GegorianCalendar getBirthday(){
return (GregorianCalendar)birthday.clone();
}
public class UMBCer{
private String firstName;
private String lastName;
private String email;
private String id;
private GregorianCalendar birthday;
public UMBCer(UMBCer other){
this.firstName = new String(other.firstName);
this.lastName = other.lastName;
this.email = other.email;
this.id = other.id;
this.birthday = (GregorianCalendar)other.birthday.clone();
}
}
public class UMBCer{
private String firstName;
private String lastName;
private String email;
private String id;
private GregorianCalendar birthday;
private boolean validEmail(String email){
return email.endsWith("@umbc.edu");
}
import java.util.Random;
public class UMBCer{
private String firstName;
private String lastName;
private String email;
private String id;
private static String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static Random rnd = new Random();
public UMBCer(String firstName, String lastName)
{
this.firstName = firstName;
this.lastName = lastName;
this.email = firstName + "." + lastName + "@umbc.edu";
this.id = alphabet.charAt(rnd.nextInt(alphabet.length())) + "" +
alphabet.charAt(rnd.nextInt(alphabet.length())) +
String.valueOf(rnd.nextInt(9) + 1) + String.valueOf(rnd.nextInt(9) + 1) +
String.valueOf(rnd.nextInt(9) + 1) + String.valueOf(rnd.nextInt(9) + 1);
}
...
}
import java.util.Scanner;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class ScannerExample{
public static void main(String[] args){
Scanner input = new Scanner( new FileInputStream("words.txt"));
while(input.hasNextLine())
{
line = input.nextLine();
}
}
}
import java.io.PrintWriter
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class WriterExample{
public static void main(String[] args){
PrintWriter output = new PrintWriter( new FileOutputStream("out.txt"))
output.println("Print this to the file");
output.close();
}
}
import java.util.Scanner;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class ScannerExample{
public static void main(String[] args){
try{
input = new Scanner( new FileInputStream("words.txt"));
while(input.hasNextLine())
{
line = input.nextLine();
}
}
catch(FileNotFoundException)
{
System.err.println("Could not open file words.txt");
}
}
}