Advertisement
joxaren

Student

Mar 29th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.02 KB | None | 0 0
  1. public class Student {
  2.     String name;
  3.     String group;
  4.  
  5.     Student(String name, String group){
  6.         this.name = name;
  7.         this.group = group;
  8.         assignRandomExamMarkandCommentOnIt();
  9.     }
  10.  
  11.     void assignRandomExamMarkandCommentOnIt() {
  12.         String[] resultIs5 = {"Keep up the good work!", "You should go to MIT with results like these!",
  13.                 "I wish you were my child!", "Come here and let me give you a kiss!"};
  14.         String[] resultIs3or4 = {"You could have done better, you know.", "I'm going to inform your parents of your performance.",
  15.                 "I am not happy with your performance.", "You should consider a career in floor sweeping."};
  16.         String[] resultIs2 = {" Get outta here, you fuckwit!", "You should be ashamed of yourself!",
  17.                 "You deserve some corporeal punishment, go fetch the belt."};
  18.  
  19.         int rand5 = (int) (Math.random() * resultIs5.length);
  20.         int rand3to4 = (int) (Math.random() * resultIs3or4.length);
  21.         int rand2 = (int) (Math.random() * resultIs2.length);
  22.  
  23.         int mark = (int) (Math.random() * (4) + 2);
  24.  
  25.         System.out.print(name + ", " + "group" + group + ", your result is " + mark + ".");
  26.         if (mark == 5) {
  27.             System.out.println(" " + resultIs5[rand5]);
  28.         }
  29.         if (mark == 3 || mark == 4) {
  30.             System.out.println(" " + resultIs3or4[rand3to4]);
  31.         }
  32.         if (mark == 2) {
  33.             System.out.println(" " + resultIs2[rand2]);
  34.         }
  35.     }
  36. }
  37.  
  38. _____________________
  39.  
  40. public class StudentTestDrive {
  41.     public static void main(String[] args) {
  42.  
  43.         System.out.println("Attention, students! Here are your exam results, listen closely.");
  44.  
  45.         Student daria = new Student("Daria Morgendorfer", " 8B");
  46.         Student jane = new Student("Jane Lane", " 8B");
  47.         Student trent = new Student("Trent Lane", "... what are you doing here, you're twenty five and unemployed! Anyway");
  48.  
  49.         System.out.println("Class dismissed, everybody out!");
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement