From 390cbbe83b803fe6a01be0baf659804755082de1 Mon Sep 17 00:00:00 2001 From: Chris Mayfield Date: Fri, 6 May 2016 09:33:10 -0400 Subject: [PATCH 1/4] sync with 6.1.0 --- LICENSE | 2 +- README.md | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/LICENSE b/LICENSE index 749dcd6..89ed830 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 Allen Downey +Copyright (c) 2016 Allen Downey and Chris Mayfield Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index fe3da55..10592d0 100644 --- a/README.md +++ b/README.md @@ -13,17 +13,19 @@ If you don't already have a GitHub account, you'll need to create one. After forking, you'll have your own repository on GitHub that you can use to keep track of code you write. Then you can ``clone'' the repository, which downloads a copy of the files to your computer. -* Or you could clone the repository without forking. If you choose this option, you don't need a GitHub account, but you won't be able to save your changes back in GitHub. +* Alternatively, you could clone the repository without forking. +If you choose this option, you don't need a GitHub account, but you won't be able to save your changes back in GitHub. * If you don't want to use Git at all, you can download the code in a zip archive using the "Download ZIP" button on this page, or [this link](http://tinyurl.com/ThinkJavaCodeZip). -To clone a repository, you need a Git client installed on your computer. The URL of this repository is `https://github.com/AllenDowney/ThinkJavaCode.git`. If you use Git from the command line, you can clone it like this: +To clone a repository, you need a Git client installed on your computer. +The URL of this repository is `https://github.com/AllenDowney/ThinkJavaCode.git`. +If you use Git from the command line, you can clone it like this: git clone https://github.com/AllenDowney/ThinkJavaCode.git After you clone the repository or unzip the zip file, you should have a directory called `ThinkJavaCode` with a subdirectory for each chapter in the book. -All the examples in this book were developed and tested using Java SE Development Kit 7. +All examples in this book were developed and tested using Java SE Development Kit 8. If you are using a more recent version, the examples in this book should still work. If you are using an older version, some of them may not. - From bc927971a210887c511c9ccd942c6728a79f806c Mon Sep 17 00:00:00 2001 From: Chris Mayfield Date: Tue, 6 Sep 2016 21:27:43 -0400 Subject: [PATCH 2/4] checkstyle 7.1.1 --- ap02/Moire.java | 2 +- ch05/Conditional.java | 2 -- ch05/Exercise.java | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ap02/Moire.java b/ap02/Moire.java index 750bad3..8e7247f 100644 --- a/ap02/Moire.java +++ b/ap02/Moire.java @@ -18,7 +18,7 @@ public static void main(String[] args) { public void paint(Graphics g) { int i = 90; while (i < getWidth()) { - g.drawOval (0, 0, i, i); + g.drawOval(0, 0, i, i); i = i + 3; } } diff --git a/ch05/Conditional.java b/ch05/Conditional.java index 1fd36ce..f2d6d19 100644 --- a/ch05/Conditional.java +++ b/ch05/Conditional.java @@ -1,5 +1,3 @@ -import java.util.Scanner; - /** * Examples from Chapter 5. */ diff --git a/ch05/Exercise.java b/ch05/Exercise.java index 46774e0..dbbb6e9 100644 --- a/ch05/Exercise.java +++ b/ch05/Exercise.java @@ -18,7 +18,7 @@ public static void main(String[] args) { public static void clink(int fork) { System.out.print("It's "); - zoop("breakfast ", fork) ; + zoop("breakfast ", fork); } public static void ping(String strangStrung) { From 9fb1ef4d514055e2e31c56b786ccbd6c384e41a5 Mon Sep 17 00:00:00 2001 From: Chris Mayfield Date: Tue, 27 Dec 2016 12:27:10 -0500 Subject: [PATCH 3/4] sync with 6.1.2 --- ch05/Logarithm.java | 12 ++++++------ ch07/Tables.java | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ch05/Logarithm.java b/ch05/Logarithm.java index bc21157..5c5986a 100644 --- a/ch05/Logarithm.java +++ b/ch05/Logarithm.java @@ -6,11 +6,13 @@ public static void main(String[] args) { System.out.println("printLogarithm"); printLogarithm(3.0); + Scanner in = new Scanner(System.in); + System.out.println("scandouble"); - scanDouble(); + scanDouble(in); System.out.println("scandouble2"); - scanDouble2(); + scanDouble2(in); } public static void printLogarithm(double x) { @@ -22,15 +24,13 @@ public static void printLogarithm(double x) { System.out.println("The log of x is " + result); } - public static void scanDouble() { - Scanner in = new Scanner(System.in); + public static void scanDouble(Scanner in) { System.out.print("Enter a number: "); double x = in.nextDouble(); printLogarithm(x); } - public static void scanDouble2() { - Scanner in = new Scanner(System.in); + public static void scanDouble2(Scanner in) { System.out.print("Enter a number: "); if (!in.hasNextDouble()) { String word = in.next(); diff --git a/ch07/Tables.java b/ch07/Tables.java index 44e9e62..3e33905 100644 --- a/ch07/Tables.java +++ b/ch07/Tables.java @@ -6,7 +6,7 @@ public class Tables { public static void example() { int i = 1; while (i < 10) { - double x = (double) i; + double x = i; System.out.println(x + " " + Math.log(x)); i = i + 1; } @@ -15,7 +15,7 @@ public static void example() { public static void example2() { int i = 1; while (i < 10) { - double x = (double) i; + double x = i; System.out.println(x + " " + Math.log(x) / Math.log(2)); i = i + 1; } @@ -25,7 +25,7 @@ public static void example3() { final double LOG2 = Math.log(2); int i = 1; while (i < 100) { - double x = (double) i; + double x = i; System.out.println(x + " " + Math.log(x) / LOG2); i = i * 2; } From 373dd806db8685fdbf7a5fa2e9c8c8eb4028cf3b Mon Sep 17 00:00:00 2001 From: Jayaprabhakar Date: Wed, 15 Nov 2017 03:48:30 -0800 Subject: [PATCH 4/4] Add link to source code hosted on Codiva online java ide Let students directly edit, compile and run java programs on Codiva.io Online Java IDE. This is suitable for beginneers of Java, because they don't have to understand Git, in their early days of learning to code. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 10592d0..0a68248 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Git is a version control system that allows you to keep track of the files that A collection of files under Git's control is called a repository. There are several ways you can work with the code: +* You can edit and run the code on [Codiva online java IDE](https://www.codiva.io/tutorials/thinkjavacode). * You can create a copy of this repository on GitHub by pressing the "Fork" button in the upper right. If you don't already have a GitHub account, you'll need to create one.