From ggc
|
01 packagepackage is used to name the directory or folder a class is in jam;
02
03 importimport means to make the classes and/or packages available in this program wiki.Wiki;
04 importimport means to make the classes and/or packages available in this program java.util.*;
05 /**
06 * All about my application here.
07 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
08 */
09 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects DoorTester
10 {open braces start code blocks and must be matched with a close brace
11 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args)
12 {open braces start code blocks and must be matched with a close brace
13 Door door1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Door(falsefalse is a value for the boolean type and means not true, falsefalse is a value for the boolean type and means not true, 1);
14 Door door2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Door(falsefalse is a value for the boolean type and means not true, falsefalse is a value for the boolean type and means not true, 2);
15 Door door3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Door(truetrue is the boolean value that is the opposite of false, falsefalse is a value for the boolean type and means not true, 3);
16 Wiki.out.println("The doors to start:");
17 Wiki.out.println(door1);
18 Wiki.out.println(door2);
19 Wiki.out.println(door3);
20 Wiki.out.println("\nChoose a door (1, 2, or 3)");
21 Scanner scanner=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Scanner(Wiki.in);
22 intint is the type for whole numbers and it is short for integer firstChoice=this assignment operator makes the left side equal to the right sidescanner.nextInt();
23 ifif executes the next statement only if the condition in parenthesis evaluates to true(door1.canOpenFirst(firstChoice))
24 {open braces start code blocks and must be matched with a close brace
25 Wiki.out.println("Opening door 1 with a donkey behind it.") ;
26 door1.open();
27 }close braces end code blocks and must match an earlier open brace
28 ifif executes the next statement only if the condition in parenthesis evaluates to true(door2.canOpenFirst(firstChoice))
29 {open braces start code blocks and must be matched with a close brace
30 Wiki.out.println("Opening door 2 with a donkey behind it.") ;
31 door2.open();
32 }close braces end code blocks and must match an earlier open brace
33 ifif executes the next statement only if the condition in parenthesis evaluates to true(door3.canOpenFirst(firstChoice))
34 {open braces start code blocks and must be matched with a close brace
35 Wiki.out.println("Opening door 3 with a donkey behind it.") ;
36 door3.open();
37 }close braces end code blocks and must match an earlier open brace
38
39 Wiki.out.println("Stay or switch?");
40 String answer=this assignment operator makes the left side equal to the right sidescanner.next();
41 booleanboolean is a type that is either true or false won=this assignment operator makes the left side equal to the right sidefalsefalse is a value for the boolean type and means not true;
42 ifif executes the next statement only if the condition in parenthesis evaluates to true(answer.toLowerCase().equals("stay"))
43 {open braces start code blocks and must be matched with a close brace
44 ifif executes the next statement only if the condition in parenthesis evaluates to true(firstChoice==this is the comparison operator which evaluates to true if both sides are the same1)
45 {open braces start code blocks and must be matched with a close brace
46 ifif executes the next statement only if the condition in parenthesis evaluates to true(door1.isPrize())
47 won=this assignment operator makes the left side equal to the right sidetruetrue is the boolean value that is the opposite of false;
48 }close braces end code blocks and must match an earlier open brace
49 ifif executes the next statement only if the condition in parenthesis evaluates to true(firstChoice==this is the comparison operator which evaluates to true if both sides are the same2)
50 {open braces start code blocks and must be matched with a close brace
51 ifif executes the next statement only if the condition in parenthesis evaluates to true(door2.isPrize())
52 won=this assignment operator makes the left side equal to the right sidetruetrue is the boolean value that is the opposite of false;
53 }close braces end code blocks and must match an earlier open brace
54 ifif executes the next statement only if the condition in parenthesis evaluates to true(firstChoice==this is the comparison operator which evaluates to true if both sides are the same3)
55 {open braces start code blocks and must be matched with a close brace
56 ifif executes the next statement only if the condition in parenthesis evaluates to true(door3.isPrize())
57 won=this assignment operator makes the left side equal to the right sidetruetrue is the boolean value that is the opposite of false;
58 }close braces end code blocks and must match an earlier open brace
59 }close braces end code blocks and must match an earlier open brace
60 elseelse is what happens when the if condition is false
61 {open braces start code blocks and must be matched with a close brace
62 ifif executes the next statement only if the condition in parenthesis evaluates to true(firstChoice==this is the comparison operator which evaluates to true if both sides are the same1)
63 {open braces start code blocks and must be matched with a close brace
64 ifif executes the next statement only if the condition in parenthesis evaluates to true(!this is the not operator, which changes true to false and false to truedoor1.isPrize())
65 won=this assignment operator makes the left side equal to the right sidetruetrue is the boolean value that is the opposite of false;
66 }close braces end code blocks and must match an earlier open brace
67 ifif executes the next statement only if the condition in parenthesis evaluates to true(firstChoice==this is the comparison operator which evaluates to true if both sides are the same2)
68 {open braces start code blocks and must be matched with a close brace
69 ifif executes the next statement only if the condition in parenthesis evaluates to true(!this is the not operator, which changes true to false and false to truedoor2.isPrize())
70 won=this assignment operator makes the left side equal to the right sidetruetrue is the boolean value that is the opposite of false;
71 }close braces end code blocks and must match an earlier open brace
72 ifif executes the next statement only if the condition in parenthesis evaluates to true(firstChoice==this is the comparison operator which evaluates to true if both sides are the same3)
73 {open braces start code blocks and must be matched with a close brace
74 ifif executes the next statement only if the condition in parenthesis evaluates to true(!this is the not operator, which changes true to false and false to truedoor3.isPrize())
75 won=this assignment operator makes the left side equal to the right sidetruetrue is the boolean value that is the opposite of false;
76 }close braces end code blocks and must match an earlier open brace
77 }close braces end code blocks and must match an earlier open brace
78 door1.open();
79 door2.open();
80 door3.open();
81 ifif executes the next statement only if the condition in parenthesis evaluates to true(won)
82 Wiki.out.println("You won a brand new Pinto!");
83 elseelse is what happens when the if condition is false
84 Wiki.out.println("You won your very own herd of male goats.");
85
86
87 }close braces end code blocks and must match an earlier open brace
88 }close braces end code blocks and must match an earlier open brace
|
Download/View jam/DoorTester.java