Kr Younger пре 6 година
родитељ
комит
47d58b034c
1 измењених фајлова са 87 додато и 0 уклоњено
  1. 87
    0
      codingSamples.md

+ 87
- 0
codingSamples.md Прегледај датотеку

@@ -0,0 +1,87 @@
1
+# Java Coding Samples 
2
+
3
+Various Java programs to illustrate various concepts from an old CS course at UTexas.edu.
4
+
5
+*   A [Hello World!](javacode/codeSamples/HelloWorld.java) Java program.
6
+    
7
+*   [Calling Methods](javacode/codeSamples/CallingMethodsInSameClass.java). A sample of how to call methods in the same class.
8
+    
9
+*   [For loop](javacode/codeSamples/Factorial.java). A simple example of using for loops to calculate factorial. Uses the built in int data type so only good to 13!
10
+    
11
+*   [Enhanced for loop](javacode/codeSamples/EnhancedFor.java)
12
+    
13
+*   [Value Parameters](javacode/codeSamples/PrimitiveParameters.java): An example that shows the behavior of value parameters. In Java all parameters are passed by value. 
14
+    
15
+*   [String Example](javacode/codeSamples/StringExample.java). A few brief examples of String manipulations.
16
+    
17
+*   [BinaryConverter](javacode/codeSamples/BinaryConverter.java). A program with examples of various Java syntax that converts a base 10 int to base 2 String.
18
+    
19
+*   [PrimeEx](javacode/codeSamples/PrimeEx.java) A program with various approaches to determine if an int is prime or not. Used to demonstrate Java syntax. You need the [Stopwatch](javacode/utilities/Stopwatch.java) class, a non standard Java class, as well.
20
+    
21
+*   [Pointers as Value parameters](javacode/codeSamples/ObjectVarsAsParameters.java)
22
+    
23
+*   [Array Examples](javacode/codeSamples/ArrayExamples.java)
24
+    
25
+*   [2D array Example](javacode/codeSamples/FilterExample.java). A simplified version of filtering a picture represented by ints.
26
+    
27
+*   [2D array example](javacode/codeSamples/Life.java). Very simple version of the Conway's Game of Life.
28
+    
29
+*   [Getting input from Keyboard with Scanner class](javacode/codeSamples/ScannerAndKeyboard.java)
30
+    
31
+*   [Reading ints from file with Scanner class](javacode/codeSamples/ReadAndPrintScores.java)
32
+    
33
+*   [Writing ints to file](javacode/codeSamples/WriteToFile.java)
34
+    
35
+*   [Connecting to and reading from a web page.](javacode/codeSamples/URLExpSimple.java)
36
+    
37
+*   [Program to create ASCII frequency table from file and url.](javacode/codeSamples/FreqTableExampleOriginal.java) Demonstration of try / catch blocks. The CIA 2008 Factbook may be downloaded from [Project Gutenberg](http://www.gutenberg.org/cache/epub/29233/pg29233.txt).
38
+    
39
+*   [IntListVer1](javacode/codeSamples/IntListVer1.java) First version of the IntList class developed in class. Developing class to illustrate various class design and implementation issues in Java.
40
+    
41
+*   [IntListTesterVer1](javacode/codeSamples/IntListTesterVer1.java)
42
+    
43
+*   [IntListVer2](javacode/codeSamples/IntListVer2.java) Added default add method, equals method, and toString methods. Includes versions of toString using String concatenation and StringBuffer to illustarte performance differences.
44
+    
45
+*   [IntListTesterVer2](javacode/codeSamples/IntListTesterVer2.java)
46
+    
47
+*   [IntListVer3](javacode/codeSamples/IntListVer3.java). Added insert and remove methods.
48
+    
49
+*   [SortedIntList](javacode/codeSamples/SortedIntList.java). Inherits from InListVer3 to create a SortedIntList. Class is "broken" because random insertions still allowed.
50
+    
51
+*   [GenericList](javacode/codeSamples/GenericList.java). Altered the list to store anything, not just ints.
52
+    
53
+*   [Die](javacode/codeSamples/Die.java) class. A class that models a playing die.
54
+    
55
+*   [DemoClass](javacode/codeSamples/DemoClass.java): This illustrates some of the more confusing concepts in class syntax and mechanics such as constructors, static vs. instance methods, and method overloading. 
56
+    
57
+*   [Stopwatch class](javacode/utilities/Stopwatch.java). A class for measuring how long it takes for a program to run.
58
+    
59
+    *   [Documentation for Stopwatch class.](javacode/utilities/Stopwatch.html)
60
+        
61
+*   [Create a Set](javacode/codeSamples/CreateASet.java). A method that using polymorphism to create a set from an array.
62
+    
63
+*   [Recursion examples](javacode/codeSamples/RecursionExampleDirectory.java). Includes examples on finding space taken up by files in a directory including all files in all subdirectories, recursive factorial, recursive power, recursive Fibonacci numbers, and a simple knapsack problem.
64
+    
65
+*   [Eight Queens example](javacode/codeSamples/EightQueens.java). Code to find a a solution to an N queens problem. Note the queensAreSafe method has not been completed.
66
+    
67
+*   [Airlines example](javacode/codeSamples/AirlineProblem.java). Determine if airlines can be moved from airline to another based on network of airline partners. Here is a [sample input file](javacode/codeSamples/airlines.txt).
68
+    
69
+*   [Minesweeper](javacode/codeSamples/MineSweeper.java). Another example of recursion from the game minesweeper.
70
+    
71
+*   [GenericListVersion2](javacode/codeSamples/GenericListVersion2.java). Changed the GenericList class so that it implements the [Iterable](http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html) interface in order to demonstrate how to implement an [iterator](http://java.sun.com/javase/6/docs/api/java/util/Iterator.html) using an inner class.
72
+    
73
+*   [GenericListVersion3](javacode/GenericList.java). Changed GenericList so it is generic based on Java generics syntax instead of relying on Object.
74
+    
75
+*   [ListNode](javacode/codeSamples/ListNode.java). A singly linked node class used to build linked lists
76
+    
77
+*   [IList](javacode/LinkedList/IList.java). A simple list interface
78
+    
79
+*   [LinkedList](javacode/codeSamples/LinkedList.java). Similar to the LinkedList developed in class. Does not contain all the methods you would expect of a LinkedList. Also implements the iterator remove method in O(N) time. An O(1) time remove method is possible.
80
+    
81
+*   [UnsortedHashSet](javacode/codeSamples/UnsortedHashSet.java) \- An unsorted set that uses a hashtable with closed address hashing to store values. Currently only the add method is implemented.
82
+    
83
+*   [UnsortedSetTest](javacode/codeSamples/UnsortedSetTest.java) - A method to compare Java's TreeSet and HashSet to the BianrySearchTree, UnsortedSet, and UnsortedHashSet classes developed in class. Note you need a lot of other files for this to work.
84
+    
85
+*   [SimpleWordCount](javacode/codeSamples/SimpleWordCounter.java) \- Program demonstrating use of a map to count the frequency of words in a file.
86
+    
87
+*   [WordCount](https://www.cs.utexas.edu/~scottm/cs314/javacode/CodingSamples/WordCount.java) \- Program  that compares counting words in files using an ArrayList and a Map.