Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9318e32

Browse files
Merge pull request #74 from HarryDulaney/new-solutions
Add slides.jpg + clean up
2 parents 6c6acec + 6305500 commit 9318e32

34 files changed

+151
-231
lines changed

‎README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,25 @@ object-oriented, GUI programming, advanced GUI and Web programming using Java...
2020
<h1 style="text-align: center">Companion Content</h1>
2121
<h6>Additional online learning material that came with the books</h6>
2222

23-
#### <a href="http://liveexample.pearsoncmg.com/liang/intro10e">10th Edition Companion Website</a>
23+
### <a href="https://media.pearsoncmg.com/ph/esm/ecs_liang_ijp_11/cw/#web-chapters">Bonus Chapters Online</a>
2424

25-
#### <a href="#self-check-quizs">Self-Check Chapter Quiz's</a>
25+
### <a href="https://liveexample.pearsoncmg.com/CheckExercise/faces/CheckExercise.xhtml?chapter=1&programName=Exercise01_01">Exercise Check Tool</a>
2626

27-
#### <a href="https://liveexample.pearsoncmg.com/CheckExercise/faces/CheckExercise.xhtml?chapter=1&programName=Exercise01_01">Exercise Check Tool</a>
27+
### <a href="https://media.pearsoncmg.com/ph/esm/ecs_liang_java_13e/cw/#videonotes">Video Notes</a>
2828

29-
#### <a href="https://liveexample.pearsoncmg.com/javarevel2e.html">Hints to Quizzes and Programming Projects</a>
29+
### <a href="#self-check-quizs">Self-Check Chapter Quiz's</a>
3030

31-
#### <a href='#checkpoint-answers'>Checkpoint Answers</a>
31+
### <a href="https://liveexample.pearsoncmg.com/javarevel2e.html">Hints to Quizzes and Programming Projects</a>
3232

33-
#### <a href="https://media.pearsoncmg.com/ph/esm/ecs_liang_ijp_10/ExampleByChapters.html">Example Programs By Chapter</a>
33+
### <a href='#checkpoint-answers'>Checkpoint Answers</a>
3434

35-
#### <a href="http://liveexample.pearsoncmg.com/liang/animation/animation.html">Algorithm Animations</a>
35+
### <a href='https://media.pearsoncmg.com/ph/esm/ecs_liang_java_13e/downloads/even_numbered_exercise_UML_diagram/EvenNumberedExerciseUMLDiagram.html'>UML Diagrams for Chapter 9 - 13</a>
3636

37-
#### <a href="https://media.pearsoncmg.com/ph/esm/ecs_liang_ijp_10/supplement/Supplement1dcodingguidelines.html">Java Coding Style Guidelines</a>
37+
### <a href="https://media.pearsoncmg.com/ph/esm/ecs_liang_ijp_10/ExampleByChapters.html">Example Programs By Chapter</a>
38+
39+
### <a href="http://liveexample.pearsoncmg.com/liang/animation/animation.html">Algorithm Animations</a>
40+
41+
### <a href="https://media.pearsoncmg.com/ph/esm/ecs_liang_ijp_10/supplement/Supplement1dcodingguidelines.html">Java Coding Style Guidelines</a>
3842

3943
____
4044
<span id="contribute"><span/>
@@ -174,9 +178,9 @@ Exercises Needed: 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31
174178
<strong>Chapter 30</strong></a> - Multithreading and Parallel Programming</li><br>
175179
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/ch_31">
176180
<strong>Chapter 31</strong></a> - Networking </li><br>
177-
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/ch_32">
178-
<strong>Chapter 32</strong></a> - Java Database Programming</li><br>
179-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/">-->
181+
<li><!-- <a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/ch_32"> -->
182+
<strong>Chapter 32</strong><!-- </a> --> - Java Database Programming</li><br>
183+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/ch_33">-->
180184
<strong>Chapter 33</strong><!--</a>--> - Java Server Faces</li><br>
181185
</ul>
182186

‎ch_14/Exercise14_14.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public class Exercise14_14 extends Application {
2222

2323
@Override
2424
public void start(Stage primaryStage) {
25-
2625
Pane pane = new Pane();
2726
/* Create the bottomLeftAlg 2D-rectangle part of the cube */
2827
Rectangle bottomLeftAlignedRectangle = new Rectangle(0, 0);

‎ch_14/Exercise14_29.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ public void start(Stage primaryStage) {
2828
}
2929

3030
static class BeanMachinePane extends Pane {
31-
private final int triangleSize;
31+
private final int numberOfPins;
3232
private final int numberOfSlots;
3333
private Circle[] pins;
3434

3535
public BeanMachinePane(double width, double height, int numberOfSlots) {
3636
setWidth(width);
3737
setHeight(height);
3838
this.numberOfSlots = numberOfSlots;
39-
this.triangleSize = circleCount(numberOfSlots);
39+
this.numberOfPins = getNumberOfPins(numberOfSlots);
4040
paint();
4141
}
4242

@@ -49,7 +49,7 @@ private void paint() {
4949
paneHeight * 0.8);
5050

5151
double distance = (lowerLine.getEndX() - lowerLine.getStartX()) / numberOfSlots;
52-
pins = new Circle[triangleSize];
52+
pins = new Circle[numberOfPins];
5353
int index = 0;
5454
for (int i = 1; i < numberOfSlots; i++) {
5555
double x = lowerLine.getStartX() + (i * distance * 0.50) + distance / 2;
@@ -97,12 +97,18 @@ private void paint() {
9797
getChildren().addAll(outlineShape);
9898
}
9999

100-
private int circleCount(int slots) {
101-
int count = 0;
102-
while (slots-- > 1) {
103-
count += slots;
104-
}
105-
return count;
100+
/**
101+
* @param slots the number of slots in the bean machine
102+
* @return the number of pins in the bean machine
103+
*/
104+
int getNumberOfPins(int slots) {
105+
int numPins = 0;
106+
do {
107+
slots--;
108+
numPins += slots;
109+
} while (slots > 1);
110+
111+
return numPins;
106112
}
107113

108114
}

‎ch_15/Exercise15_30.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ public class Exercise15_30 extends Application {
3333
public void start(Stage primaryStage) {
3434
Image[] image = new Image[26];
3535

36-
for (int i = 1; i <= 25; i++) {
37-
String imagePath = "resources" + File.separator + "images" +
38-
File.separator + "card" + File.separator + i + ".png";
36+
for (int i = 0; i < 25; i++) {
37+
String imagePath = "resources" + File.separator + "images" + File.separator + "slide" + i + ".jpg";
3938
image[i] = new Image(imagePath);
4039
}
4140

‎ch_28/Exercise28_02.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

‎ch_28/exercise28_02/Exercise28_02.java

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package ch_28.exercise28_02;
2+
3+
import java.io.File;
4+
import java.io.FileNotFoundException;
5+
import java.io.IOException;
6+
import java.io.PrintWriter;
7+
import java.nio.file.Files;
8+
import java.nio.file.Paths;
9+
10+
/**
11+
* *28.2 (Create a file for a graph) Modify Listing 28.1, TestGraph.java, to create a file
12+
* representing graph1. The file format is described in Programming Exercise 28.1.
13+
* Create the file from the array defined in lines 8–21 in Listing 28.1. The number
14+
* of vertices for the graph is 12, which will be stored in the first line of the file.
15+
* The contents of the file should be as follows:
16+
* 12
17+
* 0 1 3 5
18+
* 1 0 2 3
19+
* 2 1 3 4 10
20+
* 3 0 1 2 4 5
21+
* 4 2 3 5 7 8 10
22+
* 5 0 3 4 6 7
23+
* 6 5 7
24+
* 7 4 5 6 8
25+
* 8 4 7 9 10 11
26+
* 9 8 11
27+
* 10 2 4 8 11
28+
*/
29+
public class Exercise28_02 {
30+
public static void main(String[] args) throws IOException {
31+
String packageName = Exercise28_02.class.getPackage().getName();
32+
String[] packageParts = packageName.split("\\.");
33+
packageName = String.join(File.separator, packageParts);
34+
String filePath = packageName + File.separator + "Exercise28_02.txt";
35+
if (Files.deleteIfExists(Paths.get(filePath))) {
36+
System.out.println("Deleting old: " + filePath);
37+
}
38+
try {
39+
PrintWriter output = new PrintWriter(filePath);
40+
System.out.println("Writing new: " + filePath);
41+
writeGraphToFile(output, getVertices(), getEdges());
42+
System.out.println("Done!");
43+
output.close();
44+
} catch (FileNotFoundException fileNotFoundException) {
45+
System.out.println("FileNotFoundException message: " + fileNotFoundException.getMessage());
46+
System.out.println("FileNotFoundException on filePath: " + filePath);
47+
48+
}
49+
50+
}
51+
52+
private static void writeGraphToFile(PrintWriter output, String[] vertices, int[][] edges) {
53+
int numberOfVertices = vertices.length;
54+
output.println(numberOfVertices);
55+
for (int startingVertex = 0; startingVertex < numberOfVertices; startingVertex++) {
56+
output.print(startingVertex + " ");
57+
int count = 0;
58+
for (int[] edge : edges) {
59+
if (edge[0] == startingVertex) {
60+
count++;
61+
if (count == 1) {
62+
output.print(edge[1]);
63+
} else {
64+
output.print(" " + edge[1]);
65+
}
66+
}
67+
}
68+
if (count > 0) output.println();
69+
}
70+
}
71+
72+
private static String[] getVertices() {
73+
return new String[]{"Seattle", "San Francisco", "Los Angeles",
74+
"Denver", "Kansas City", "Chicago", "Boston", "New York",
75+
"Atlanta", "Miami", "Dallas", "Houston"};
76+
}
77+
78+
private static int[][] getEdges() {
79+
return new int[][]{
80+
{0, 1}, {0, 3}, {0, 5},
81+
{1, 0}, {1, 2}, {1, 3},
82+
{2, 1}, {2, 3}, {2, 4}, {2, 10},
83+
{3, 0}, {3, 1}, {3, 2}, {3, 4}, {3, 5},
84+
{4, 2}, {4, 3}, {4, 5}, {4, 7}, {4, 8}, {4, 10},
85+
{5, 0}, {5, 3}, {5, 4}, {5, 6}, {5, 7},
86+
{6, 5}, {6, 7},
87+
{7, 4}, {7, 5}, {7, 6}, {7, 8},
88+
{8, 4}, {8, 7}, {8, 9}, {8, 10}, {8, 11},
89+
{9, 8}, {9, 11},
90+
{10, 2}, {10, 4}, {10, 8}, {10, 11},
91+
{11, 8}, {11, 9}, {11, 10}
92+
};
93+
}
94+
95+
}

‎ch_28/exercise28_02/Exercise28_02.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
12
2+
0 1 3 5
3+
1 0 2 3
4+
2 1 3 4 10
5+
3 0 1 2 4 5
6+
4 2 3 5 7 8 10
7+
5 0 3 4 6 7
8+
6 5 7
9+
7 4 5 6 8
10+
8 4 7 9 10 11
11+
9 8 11
12+
10 2 4 8 11
13+
11 8 9 10

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /