Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student {
- String name;
- String group;
- Student(String name, String group){
- this.name = name;
- this.group = group;
- assignRandomExamMarkandCommentOnIt();
- }
- void assignRandomExamMarkandCommentOnIt() {
- String[] resultIs5 = {"Keep up the good work!", "You should go to MIT with results like these!",
- "I wish you were my child!", "Come here and let me give you a kiss!"};
- String[] resultIs3or4 = {"You could have done better, you know.", "I'm going to inform your parents of your performance.",
- "I am not happy with your performance.", "You should consider a career in floor sweeping."};
- String[] resultIs2 = {" Get outta here, you fuckwit!", "You should be ashamed of yourself!",
- "You deserve some corporeal punishment, go fetch the belt."};
- int rand5 = (int) (Math.random() * resultIs5.length);
- int rand3to4 = (int) (Math.random() * resultIs3or4.length);
- int rand2 = (int) (Math.random() * resultIs2.length);
- int mark = (int) (Math.random() * (4) + 2);
- System.out.print(name + ", " + "group" + group + ", your result is " + mark + ".");
- if (mark == 5) {
- System.out.println(" " + resultIs5[rand5]);
- }
- if (mark == 3 || mark == 4) {
- System.out.println(" " + resultIs3or4[rand3to4]);
- }
- if (mark == 2) {
- System.out.println(" " + resultIs2[rand2]);
- }
- }
- }
- _____________________
- public class StudentTestDrive {
- public static void main(String[] args) {
- System.out.println("Attention, students! Here are your exam results, listen closely.");
- Student daria = new Student("Daria Morgendorfer", " 8B");
- Student jane = new Student("Jane Lane", " 8B");
- Student trent = new Student("Trent Lane", "... what are you doing here, you're twenty five and unemployed! Anyway");
- System.out.println("Class dismissed, everybody out!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement