コード例 #1
0
ファイル: Test.java プロジェクト: stawny/studies-dyplomowy
 private static void answer() {
   Research[] allResearches = service.findAllResearches();
   for (int i = 0; i < allResearches.length; i++) {
     System.out.println(i + ": " + allResearches[i].getName());
   }
   Research mResearch = allResearches[sc.nextInt()];
   Question[] questions = service.findAllQuestionsByResearch(mResearch);
   AnswerList al = new AnswerList();
   al.setResearch(mResearch);
   List<Answer> ans = new ArrayList<Answer>();
   for (Question question : questions) {
     System.out.print(question.getQuestion() + " > ");
     Answer answer = new Answer();
     answer.setQuestion(question);
     answer.setAnswer(sc.next());
     ans.add(answer);
   }
   al.setAnswers(ans);
   service.persist(al);
 }
コード例 #2
0
ファイル: Test.java プロジェクト: stawny/studies-dyplomowy
 private static void createNewResearch() {
   Research r = new Research();
   r.setCreationDate(new Date());
   System.out.print("nazwa tabeli >");
   r.setName(sc.next());
   ArrayList<Question> qs = new ArrayList<Question>();
   while (true) {
     System.out.print("dodac? > ");
     boolean b = sc.nextBoolean();
     if (!b) {
       break;
     }
     Question question = new Question();
     System.out.print("tresc pytania >");
     question.setQuestion(sc.next());
     System.out.print("typ 1.boolean, 2.string, 3.date, 4.integer>");
     switch (sc.nextInt()) {
       case 1:
         question.setQuestionType(QuestionType.BOOLEAN);
         break;
       case 2:
         question.setQuestionType(QuestionType.STRING);
         break;
       case 3:
         question.setQuestionType(QuestionType.DATE);
         break;
       case 4:
         question.setQuestionType(QuestionType.INTEGER);
         break;
       default:
         break;
     }
     qs.add(question);
   }
   r.setQuestions(qs);
   service.persist(r);
 }