(unprocessed_information.replace("type:","").equals("teacher")) ?
(admin_accounts.add(username)) : (null);
Information stating that it's not a statement
; this can be done with an if-statement but it would be much better in terms of efficiency if it was done using the ternary operator;
If anyone could inform me what is wrong with the statement. I would really appreciate it.
function code: https://hastebin.com/heriqoripi.vbs
information about the function o - A class has an array full of strings which using a for-each loop cuts the information to create accounts ( I have yet to do the encryption because, I don't know how to do hash encryption yet.)
private void update_accounts() throws IOException{
String[] contents_Of_File = fileHandling.retrieve_contents();
String username = "";
String password = "";
String unprocessed_information = "";
int char_count = 0;
account_information = new HashMap<>();
if(contents_Of_File == null){
System.out.println("The contents of the file is empty" );}
else{
for(String S : contents_Of_File){
if(S != null){
for(char c : S.toCharArray()){
char_count++;
if(c == delimiter || c == fileHandling.getDelimiter()){
if(unprocessed_information.contains("username:")){username = unprocessed_information.replace("username:", "");}
if(unprocessed_information.contains("password:")){password = unprocessed_information.replace("password:","");}
unprocessed_information="";}
else if(char_count == S.length()){
unprocessed_information += c;
if(unprocessed_information.contains("type:")){
( unprocessed_information.replace("type:","").equals("teacher") ) ? (admin_accounts.add(username)) : (null);
}
unprocessed_information="";
}
else{
unprocessed_information += c;}
}
if(! account_information.containsKey(username)){
System.out.println("o SYSTEM - username:" + username + ", password:" + password + " - have been inputted into the databse.");}
account_information.put(username, password);
unprocessed_information = "";
char_count = 0;}
else{break;}
}
}
}