addAnswer 2.0

This commit is contained in:
borean 2024-02-13 16:46:03 +01:00
parent 213a8c6571
commit e93f3980f2

View file

@ -39,10 +39,15 @@ public class Dump extends HttpServlet {
*/
boolean nameOk(Database db, String name){
boolean result = !name.equals("");
if (result)
result = db.addName(name);
if (result) result = db.addName(name);
return result;
}
boolean answerOk(Database db, String answerOne, String answerTwo, String answerThree, String answerFour) {
boolean result = !answerOne.equals("") && !answerTwo.equals("") && !answerThree.equals("") && !answerFour.equals("");
if(result) result = db.addAnswer(answerFour, answerOne, answerTwo, answerThree, answerFour);
return result;
}
/*
* Checks if a value entered as answer is OK. Answers should be between 1 and 10.
@ -51,13 +56,9 @@ public class Dump extends HttpServlet {
return value > 0 && value <11;
}
/// Write fn that takes params and inputs to db, returns true if succ else false if fail
// test(str a, str b, str c)
protected boolean updateAnswers(String answerOne, String answerTwo) (
/// logic
return true;
)
protected boolean updateAnswers(String answerOne, String answerTwo) {
return true;
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)