Advertisement
Advertisement
| 06.15.2008 at 09:25AM PDT, ID: 23486331 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: |
public class Name
{
private String first;//First name
private String middle;//Middle name
private String last;//Last name
private String initials;//Three character initials
// ------------------------------------------------------------
// Default constructor - to initialize the variables
// ------------------------------------------------------------
Name(){
first = "Tom";
middle = "Jim";
last = "Bob";
initials = "jjb";
}
private String newFirst , newMiddle, newLast ; // Name parts
// ------------------------------------------------------------
// Another constructor - with three parameters - if you know the first and middle and last name
// ------------------------------------------------------------
Name(String first, String middle, String last){
first = newFirst;
middle = newMiddle;
last = newLast;
}
// ------------------------------------------------------------
// Accessor methods
// ------------------------------------------------------------
public String getFirst(){
return first;
}
public String getMiddle(){
return middle;
}
public String getLast(){
return last;
}
// ------------------------------------------------------------
// Mutator methods
// ------------------------------------------------------------
public void setFirst(String newFirst){
first = newFirst;
}
public void setMiddle(String newMiddle){
middle = newMiddle;
}
public void setLast(String newLast){
last = newLast;
}
public String firstMiddleLast(){
return first + " " + middle + " " + last;
}
// ---------------------------------------------------------
// Return the Initials
// ---------------------------------------------------------
public String initials(){
return first.substring(0,1).toUpperCase()+
middle.substring(0,1).toUpperCase()+
last.substring(0,1).toUpperCase();
}
}// End Class
import java.util.Arrays;
public class TestName{
// ---------------------------------------------------------
public static void main(String[] args) throws Exception {
// Create a File instance
java.io.File file = new java.io.File("names.txt");
// Name[]nameArray;
// nameArray = createNameArray();
//Print Name Array
// printNameArray(nameArray);
// Create a Scanner for the file
java.util.Scanner input = new java.util.Scanner(file);
// Read data from a file
while (input.hasNext()) {
String first = input.next();
String middle = input.next();
String last = input.next();
Name[]nameArray;
nameArray = createNameArray();
printNameArray(nameArray);
//System.out.println(first + " " + middle + " " + last + " " + "nameArray[i].initials()");
}
// Close the file
input.close();
}
public static Name[] createNameArray() {
Name[]nameArray = new Name[10];//create an object
int j = 0;
for (int i = 0; i < nameArray.length; i++, j++) {
nameArray[j] = new Name();
}
return nameArray; //Return Name Array
}
public static void printNameArray
(Name[] nameArray){
int j = 0;
for (int i = 0; i < nameArray.length; i++, j++) {
//nameArray = java.util.Arrays.toString(nameArray[j]);
System.out.println(nameArray[j] + nameArray[j].initials());
// System.out.println(java.util.Arrays.toString(nameArray[j]));
}
}
}
|