Created
March 8, 2013 01:20
-
-
Save anonymous/5113485 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
import java.util.*; | |
public class LinkedListNode | |
{ | |
//local constants | |
//local variables | |
//BEGIN CODE | |
public UserData userInfo = new UserData("no data","no data",0); | |
public LinkedListNode link; | |
}//END LinkedListNode |
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
public class UserData | |
{ | |
//local constants | |
//local variables | |
String firstName; | |
String lastName; | |
float userScore; | |
/********************************************************** | |
* Method Name : Constructor | |
* Author : Chad Johnson | |
* Date : Mar 05, 2013 | |
* Course/Section : CSC112 - section number | |
* Program Description: This method will initialize all the | |
* data that the StudentDriver class will keep track of. | |
* | |
* BEGIN StudentDriver | |
* END StudentDriver | |
**********************************************************/ | |
public UserData(String inFirstName, String inLastName, float inUserScore) | |
{ | |
//local constants | |
//local variables | |
//Declarations | |
firstName = inFirstName; | |
lastName = inLastName; | |
userScore = inUserScore; | |
} //end main method | |
/********************************************************** | |
* Method Name : toString | |
* Author : Ryan Peters | |
* Date : Feb 11, 2013 | |
* Course/Section : CSC112 - section number | |
* Program Description: This method will returns values to the main | |
* | |
* BEGIN toString | |
* | |
* END toString | |
**********************************************************/ | |
public String toString() | |
{ | |
//local constants | |
//local variables | |
return firstName +" "+ lastName +" "+ userScore+"\n"; | |
} | |
} //end Lab03 | |
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
import java.util.*; | |
public class UserDriver | |
{ | |
/********************************************************** | |
* Method Name : Main | |
* Author : Chad Johnson | |
* Date : Feb 11, 2013 | |
* Course/Section : CSC112 - section number | |
* Program Description: This method will take data from the | |
* user, store it in its own data element(that being UserData) | |
* and that will be added to a Linked List. The user will be | |
* any part of the Linked List. | |
* | |
* | |
* BEGIN main | |
* ud.menu(); | |
* WHILE(option isn't quit) | |
* IF(option is addData) | |
* prompt user for which data | |
* add data to linked List and move pointer in list | |
* ELSEIF(option is display) | |
* IF(data has been entered) | |
* display allData until the linked list is null | |
* ELSE | |
* tell user no data was entered | |
* ENDIF | |
* ENDIF | |
* ud.menu(); | |
* ENDWHILE | |
* END main | |
**********************************************************/ | |
public static void main(String args[]) | |
{ | |
//local constants | |
final String QUIT = "-1"; | |
final String ADD_DATA = "1"; | |
final String DISPLAY = "2"; | |
final String DELETE = "3"; | |
//local variables | |
String firstName, lastName, option; | |
float score; | |
boolean dataEntered; | |
LinkedListNode head = null, curr, prev; | |
UserData userInfo = new UserData("no data2","no data2",0); | |
UserDriver ud = new UserDriver(); | |
Library myLib = new Library(); | |
//BEGIN MAIN METHOD~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
curr = head; | |
dataEntered = false; | |
ud.menu(); | |
option = Keyboard.readString(); | |
myLib.clrscr(); | |
while(!option.equalsIgnoreCase(QUIT)) | |
{ | |
if(option.equalsIgnoreCase(ADD_DATA)) | |
{ | |
//prompt user for info | |
System.out.print(" Enter First Name: "); | |
firstName = Keyboard.readString(); | |
System.out.print(" Enter Last Name: "); | |
lastName = Keyboard.readString(); | |
System.out.print(" Enter User Score: "); | |
score = Keyboard.readFloat(); | |
//gets info from user, puts it into data class, and points to next node | |
userInfo = new UserData(firstName, lastName, score); | |
curr.userInfo = userInfo; | |
prev = curr; | |
curr = curr.link; | |
dataEntered = true; | |
} | |
else if(option.equalsIgnoreCase(DISPLAY)) | |
{ | |
//checks if info has been entered yet | |
if(dataEntered == true) | |
{ | |
curr = head; | |
while(curr != null) | |
{ | |
System.out.println(" User Info: " + curr.userInfo); | |
curr = curr.link; | |
}//end while | |
} | |
else | |
{ | |
System.out.println(" No Data Entered"); | |
}//end if | |
}//end if | |
ud.menu(); | |
option = Keyboard.readString(); | |
}//end while | |
} //end main method | |
public void menu() | |
{ | |
System.out.println(" [1] Enter UserData"); | |
System.out.println(" [2] Display UserData"); | |
System.out.println(" [3] Delete UserData"); | |
System.out.println(" [-1] Quit"); | |
System.out.print( " User Input: "); | |
}//end menu method | |
} //end UserDriver |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment