Skip to content

Commit c4bd800

Browse files
JJ27actions-user
authored andcommitted
Bot: Prettified Java code!
1 parent 4e0a8aa commit c4bd800

File tree

10 files changed

+834
-822
lines changed

10 files changed

+834
-822
lines changed
Lines changed: 69 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,69 @@
1-
package com.codefortomorrow.intermediate.chapter11.practice.JingleRelays;
2-
/*
3-
This is the first of a series of problems.
4-
Credit: Christopher Haver, Computer Science, South Brunswick High School, New Jersey
5-
6-
Jingle Bell Challenge! Problem 1
7-
8-
Using ony method calls and the String song. Print
9-
"Jingle Bells Jingle Bells Jingle All The Way" vertically
10-
with one letter on each line. If you do so correctly
11-
the "You Win!" graphic will print at the bottom.
12-
13-
Only write code where the comments direct you to.
14-
*/
15-
16-
public class Jingle1{
17-
18-
public static void main(String[]args){
19-
20-
String song = ""; //DO NOT CHANGE THESE
21-
String winningString = "J\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nA\nl\nl\n\nT\nh\ne\n\nW\na\ny\n\n";
22-
23-
/***** ONLY WRITE THE CODE BETWEEN THESE COMMENTS TO CALL METHODS FOR A SOLUTION ******/
24-
song += ""; //Build your string here using the methods below to match the winning string
25-
26-
/****** WRITE CODE ABOVE, NO CHANGES BELOW *******/
27-
28-
System.out.println(song);
29-
if (song.equals(winningString))
30-
win();
31-
else
32-
System.out.println("Sorry, not quite right");
33-
34-
}
35-
36-
// YOU MAY NOT CHANGE ANY OF THE METHODS BELOW
37-
38-
public static String jingle(){
39-
return "J\ni\nn\ng\nl\ne\n\n";
40-
}
41-
42-
public static String end(double x){
43-
String outString = "A\nl\nl\n\n";
44-
x *= -3.3;
45-
if (x < 0)
46-
outString += "N\ni\ng\nh\nt\n\n";
47-
if (x != 0)
48-
outString += "T\nh\ne\n\nW\na\ny\n\n";
49-
else
50-
outString += "Y\no\nu\n\nW\na\nn\nt\n\n";
51-
return outString;
52-
}
53-
54-
public static String jingleBells(int x){
55-
String outString = "";
56-
if (x == 2){
57-
outString += jingle() + "B\ne\nl\nl\ns\n\n";
58-
}
59-
outString += jingle() + "B\ne\nl\nl\ns\n\n";
60-
return outString;
61-
62-
63-
}
64-
65-
66-
public static void win(){
67-
System.out.println("\n YOU WIN! \n");
68-
System.out.println(" ((\\o/)) ");
69-
System.out.println(" .-----//^\\\\-----. ");
70-
System.out.println(" | /`| |`\\ | ");
71-
System.out.println(" | | | | ");
72-
System.out.println(" | | | | ");
73-
System.out.println(" | | | | ");
74-
System.out.println(" '------===------' \n\n");
75-
76-
}
77-
78-
}
1+
package com.codefortomorrow.intermediate.chapter11.practice.JingleRelays;
2+
3+
/*
4+
This is the first of a series of problems.
5+
Credit: Christopher Haver, Computer Science, South Brunswick High School, New Jersey
6+
7+
Jingle Bell Challenge! Problem 1
8+
9+
Using ony method calls and the String song. Print
10+
"Jingle Bells Jingle Bells Jingle All The Way" vertically
11+
with one letter on each line. If you do so correctly
12+
the "You Win!" graphic will print at the bottom.
13+
14+
Only write code where the comments direct you to.
15+
*/
16+
17+
public class Jingle1 {
18+
19+
public static void main(String[] args) {
20+
String song = ""; //DO NOT CHANGE THESE
21+
String winningString =
22+
"J\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nA\nl\nl\n\nT\nh\ne\n\nW\na\ny\n\n";
23+
24+
/***** ONLY WRITE THE CODE BETWEEN THESE COMMENTS TO CALL METHODS FOR A SOLUTION ******/
25+
song += ""; //Build your string here using the methods below to match the winning string
26+
27+
/****** WRITE CODE ABOVE, NO CHANGES BELOW *******/
28+
29+
System.out.println(song);
30+
if (song.equals(winningString)) win(); else System.out.println(
31+
"Sorry, not quite right"
32+
);
33+
}
34+
35+
// YOU MAY NOT CHANGE ANY OF THE METHODS BELOW
36+
37+
public static String jingle() {
38+
return "J\ni\nn\ng\nl\ne\n\n";
39+
}
40+
41+
public static String end(double x) {
42+
String outString = "A\nl\nl\n\n";
43+
x *= -3.3;
44+
if (x < 0) outString += "N\ni\ng\nh\nt\n\n";
45+
if (x != 0) outString += "T\nh\ne\n\nW\na\ny\n\n"; else outString +=
46+
"Y\no\nu\n\nW\na\nn\nt\n\n";
47+
return outString;
48+
}
49+
50+
public static String jingleBells(int x) {
51+
String outString = "";
52+
if (x == 2) {
53+
outString += jingle() + "B\ne\nl\nl\ns\n\n";
54+
}
55+
outString += jingle() + "B\ne\nl\nl\ns\n\n";
56+
return outString;
57+
}
58+
59+
public static void win() {
60+
System.out.println("\n YOU WIN! \n");
61+
System.out.println(" ((\\o/)) ");
62+
System.out.println(" .-----//^\\\\-----. ");
63+
System.out.println(" | /`| |`\\ | ");
64+
System.out.println(" | | | | ");
65+
System.out.println(" | | | | ");
66+
System.out.println(" | | | | ");
67+
System.out.println(" '------===------' \n\n");
68+
}
69+
}
Lines changed: 88 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,88 @@
1-
package com.codefortomorrow.intermediate.chapter11.practice.JingleRelays;
2-
/*
3-
This is the second of a series of problems.
4-
Credit: Christopher Haver, Computer Science, South Brunswick High School, New Jersey
5-
6-
Using ony method calls and the String song. Print
7-
"Jingle Bells Jingle Bells Jingle All The Way" vertically
8-
with one letter on each line. If you do so correctly
9-
the "You Win!" graphic will print at the bottom.
10-
*/
11-
12-
public class Jingle2{
13-
14-
public static void main(String[]args){
15-
16-
String song = ""; //DO NOT CHANGE THESE
17-
String winningString = "J\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nA\nl\nl\n\nT\nh\ne\n\nW\na\ny\n\n";
18-
19-
/***** ONLY WRITE THE CODE BETWEEN THESE COMMENTS TO CALL METHODS FOR A SOLUTION ******/
20-
song += ""; //Build your string here using the methods below to match the winning string
21-
22-
23-
24-
/****** WRITE CODE ABOVE, NO CHANGES BELOW *******/
25-
26-
System.out.println(song);
27-
if (song.equals(winningString))
28-
win();
29-
else
30-
System.out.println("Sorry, not quite right");
31-
32-
}
33-
34-
// YOU MAY NOT CHANGE ANY OF THE METHODS BELOW
35-
36-
public static String ingle(){
37-
return "i\nn\ng\nl\ne\n\n";
38-
}
39-
40-
public static String J(){
41-
return "J\n";
42-
}
43-
44-
public static String B(){
45-
return "B\n";
46-
}
47-
48-
public static String end(boolean x, boolean y){
49-
String outString = "A\nl\nl\n\n";
50-
if (!(x || !y))
51-
outString += "N\ni\ng\nh\nt\n\n";
52-
if (x !=y && !y)
53-
outString += "T\nh\ne\n\nW\na\ny\n\n";
54-
if (x == y && x)
55-
outString += "Y\no\nu\n\nW\na\nn\nt\n\n";
56-
return outString;
57-
}
58-
59-
public static String ingleElls(String a, String b){
60-
61-
switch (a) {
62-
case "j": a = J();
63-
break;
64-
case "J": a = "j\n\n";
65-
break;
66-
default:
67-
a = "B\n\n";
68-
}
69-
switch (b){
70-
case "b": b = B();
71-
break;
72-
case "B": b = "b\n\n";
73-
break;
74-
default: a = "J\n\n";
75-
76-
}
77-
78-
79-
return a + ingle()+ b + "e\nl\nl\ns\n\n";
80-
81-
82-
}
83-
84-
85-
public static void win(){
86-
System.out.println("\n YOU WIN! \n");
87-
System.out.println(" ((\\o/)) ");
88-
System.out.println(" .-----//^\\\\-----. ");
89-
System.out.println(" | /`| |`\\ | ");
90-
System.out.println(" | | | | ");
91-
System.out.println(" | | | | ");
92-
System.out.println(" | | | | ");
93-
System.out.println(" '------===------' \n\n");
94-
95-
}
96-
97-
}
1+
package com.codefortomorrow.intermediate.chapter11.practice.JingleRelays;
2+
3+
/*
4+
This is the second of a series of problems.
5+
Credit: Christopher Haver, Computer Science, South Brunswick High School, New Jersey
6+
7+
Using ony method calls and the String song. Print
8+
"Jingle Bells Jingle Bells Jingle All The Way" vertically
9+
with one letter on each line. If you do so correctly
10+
the "You Win!" graphic will print at the bottom.
11+
*/
12+
13+
public class Jingle2 {
14+
15+
public static void main(String[] args) {
16+
String song = ""; //DO NOT CHANGE THESE
17+
String winningString =
18+
"J\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nA\nl\nl\n\nT\nh\ne\n\nW\na\ny\n\n";
19+
20+
/***** ONLY WRITE THE CODE BETWEEN THESE COMMENTS TO CALL METHODS FOR A SOLUTION ******/
21+
song += ""; //Build your string here using the methods below to match the winning string
22+
23+
/****** WRITE CODE ABOVE, NO CHANGES BELOW *******/
24+
25+
System.out.println(song);
26+
if (song.equals(winningString)) win(); else System.out.println(
27+
"Sorry, not quite right"
28+
);
29+
}
30+
31+
// YOU MAY NOT CHANGE ANY OF THE METHODS BELOW
32+
33+
public static String ingle() {
34+
return "i\nn\ng\nl\ne\n\n";
35+
}
36+
37+
public static String J() {
38+
return "J\n";
39+
}
40+
41+
public static String B() {
42+
return "B\n";
43+
}
44+
45+
public static String end(boolean x, boolean y) {
46+
String outString = "A\nl\nl\n\n";
47+
if (!(x || !y)) outString += "N\ni\ng\nh\nt\n\n";
48+
if (x != y && !y) outString += "T\nh\ne\n\nW\na\ny\n\n";
49+
if (x == y && x) outString += "Y\no\nu\n\nW\na\nn\nt\n\n";
50+
return outString;
51+
}
52+
53+
public static String ingleElls(String a, String b) {
54+
switch (a) {
55+
case "j":
56+
a = J();
57+
break;
58+
case "J":
59+
a = "j\n\n";
60+
break;
61+
default:
62+
a = "B\n\n";
63+
}
64+
switch (b) {
65+
case "b":
66+
b = B();
67+
break;
68+
case "B":
69+
b = "b\n\n";
70+
break;
71+
default:
72+
a = "J\n\n";
73+
}
74+
75+
return a + ingle() + b + "e\nl\nl\ns\n\n";
76+
}
77+
78+
public static void win() {
79+
System.out.println("\n YOU WIN! \n");
80+
System.out.println(" ((\\o/)) ");
81+
System.out.println(" .-----//^\\\\-----. ");
82+
System.out.println(" | /`| |`\\ | ");
83+
System.out.println(" | | | | ");
84+
System.out.println(" | | | | ");
85+
System.out.println(" | | | | ");
86+
System.out.println(" '------===------' \n\n");
87+
}
88+
}

0 commit comments

Comments
 (0)