Skip to content

Commit dbce6df

Browse files
committed
Implement solution
0 parents  commit dbce6df

File tree

9 files changed

+318
-0
lines changed

9 files changed

+318
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
out
2+
.DS_Store
3+
*.swp
4+
*.log
5+
.idea
6+
cs-hello-world-lab.iml

.learn

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
tags:
2+
- a tag
3+
languages:
4+
- a language
5+
resources:
6+
- 0

CONTRIBUTING.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Contributing to Learn.co Curriculum
2+
3+
We're really excited that you're about to contribute to the [open curriculum](https://learn.co/content-license) on [Learn.co](https://learn.co). If this is your first time contributing, please continue reading to learn how to make the most meaningful and useful impact possible.
4+
5+
## Raising an Issue to Encourage a Contribution
6+
7+
If you notice a problem with the curriculum that you believe needs improvement
8+
but you're unable to make the change yourself, you should raise a Github issue
9+
containing a clear description of the problem. Include relevant snippets of
10+
the content and/or screenshots if applicable. Curriculum owners regularly review
11+
issue lists and your issue will be prioritized and addressed as appropriate.
12+
13+
## Submitting a Pull Request to Suggest an Improvement
14+
15+
If you see an opportunity for improvement and can make the change yourself go
16+
ahead and use a typical git workflow to make it happen:
17+
18+
* Fork this curriculum repository
19+
* Make the change on your fork, with descriptive commits in the standard format
20+
* Open a Pull Request against this repo
21+
22+
A curriculum owner will review your change and approve or comment on it in due
23+
course.
24+
25+
# Why Contribute?
26+
27+
Curriculum on Learn is publicly and freely available under Learn's
28+
[Educational Content License](https://learn.co/content-license). By
29+
embracing an open-source contribution model, our goal is for the curriculum
30+
on Learn to become, in time, the best educational content the world has
31+
ever seen.
32+
33+
We need help from the community of Learners to maintain and improve the
34+
educational content. Everything from fixing typos, to correcting
35+
out-dated information, to improving exposition, to adding better examples,
36+
to fixing tests—all contributions to making the curriculum more effective are
37+
welcome.

LICENSE.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Learn.co Educational Content License
2+
3+
Copyright (c) 2015 Flatiron School, Inc
4+
5+
The Flatiron School, Inc. owns this Educational Content. However, the Flatiron School supports the development and availability of educational materials in the public domain. Therefore, the Flatiron School grants Users of the Flatiron Educational Content set forth in this repository certain rights to reuse, build upon and share such Educational Content subject to the terms of the Educational Content License set forth [here](http://learn.co/content-license) (http://learn.co/content-license). You must read carefully the terms and conditions contained in the Educational Content License as such terms govern access to and use of the Educational Content.
6+
7+
Flatiron School is willing to allow you access to and use of the Educational Content only on the condition that you accept all of the terms and conditions contained in the Educational Content License set forth [here](http://learn.co/content-license) (http://learn.co/content-license). By accessing and/or using the Educational Content, you are agreeing to all of the terms and conditions contained in the Educational Content License. If you do not agree to any or all of the terms of the Educational Content License, you are prohibited from accessing, reviewing or using in any way the Educational Content.

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# cs-hello-world-lab
2+
3+
## Objectives
4+
5+
1. Install Java SDK >= 1.7
6+
2. Print the version number to stdout
7+
8+
## Instructions
9+
10+
1. Install a recent Java runtime, if you haven't already. We recommend 1.8, but 1.7 will work, too.
11+
2. In `com.flatironschool.javacs.Main`, we've provided a function `getVersion()`. It should print your system's current version of Java.
12+
1. We want not only to make this function work but also to make sure that it prints a version compatible with the upcoming lessons.
13+
2. You might find the following information useful:
14+
1. You can print information to stdout (usually, your console) with `System.out.println()`.
15+
2. `System.getProperty()` will, you guessed it, print system properties.
16+
3. The system properties `"java.version"` and `"java.specification.version"` will both return your system's current version of Java. The former, counter-intuitively, is more specific, and you might need to manipulate the `String` that it returns a bit more.
17+
4. `Double.parseDouble()` converts a `String` to a `Double`.
18+
19+
You can run `ant` or `learn` to test your results. Good luck!

build.properties

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
path.variable.kotlin_bundled=/Applications/IntelliJ IDEA 15 CE.app/Contents/plugins/Kotlin/kotlinc
2+
path.variable.maven_repository=/Users/pletcher/.m2/repository
3+
jdk.home.1.8=/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home
4+
idea.home=/Applications/IntelliJ IDEA 15 CE.app/Contents

build.xml

+213
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="cs-hello-world-lab" default="all">
3+
4+
5+
<property file="build.properties"/>
6+
<!-- Uncomment the following property if no tests compilation is needed -->
7+
<!--
8+
<property name="skip.tests" value="true"/>
9+
-->
10+
11+
<!-- Compiler options -->
12+
13+
<property name="compiler.debug" value="on"/>
14+
<property name="compiler.generate.no.warnings" value="off"/>
15+
<property name="compiler.args" value=""/>
16+
<property name="compiler.max.memory" value="700m"/>
17+
<patternset id="ignored.files">
18+
<exclude name="**/*.hprof/**"/>
19+
<exclude name="**/*.pyc/**"/>
20+
<exclude name="**/*.pyo/**"/>
21+
<exclude name="**/*.rbc/**"/>
22+
<exclude name="**/*~/**"/>
23+
<exclude name="**/.DS_Store/**"/>
24+
<exclude name="**/.git/**"/>
25+
<exclude name="**/.hg/**"/>
26+
<exclude name="**/.svn/**"/>
27+
<exclude name="**/CVS/**"/>
28+
<exclude name="**/RCS/**"/>
29+
<exclude name="**/SCCS/**"/>
30+
<exclude name="**/__pycache__/**"/>
31+
<exclude name="**/_svn/**"/>
32+
<exclude name="**/rcs/**"/>
33+
<exclude name="**/vssver.scc/**"/>
34+
<exclude name="**/vssver2.scc/**"/>
35+
</patternset>
36+
<patternset id="library.patterns">
37+
<include name="*.war"/>
38+
<include name="*.swc"/>
39+
<include name="*.apk"/>
40+
<include name="*.zip"/>
41+
<include name="*.ear"/>
42+
<include name="*.egg"/>
43+
<include name="*.ane"/>
44+
<include name="*.jar"/>
45+
</patternset>
46+
<patternset id="compiler.resources">
47+
<exclude name="**/?*.java"/>
48+
<exclude name="**/?*.form"/>
49+
<exclude name="**/?*.class"/>
50+
<exclude name="**/?*.groovy"/>
51+
<exclude name="**/?*.scala"/>
52+
<exclude name="**/?*.flex"/>
53+
<exclude name="**/?*.kt"/>
54+
<exclude name="**/?*.clj"/>
55+
<exclude name="**/?*.aj"/>
56+
</patternset>
57+
58+
<!-- JDK definitions -->
59+
60+
<property name="jdk.bin.1.8" value="${jdk.home.1.8}/bin"/>
61+
<path id="jdk.classpath.1.8">
62+
<fileset dir="${jdk.home.1.8}">
63+
<include name="jre/lib/charsets.jar"/>
64+
<include name="jre/lib/deploy.jar"/>
65+
<include name="jre/lib/ext/cldrdata.jar"/>
66+
<include name="jre/lib/ext/dnsns.jar"/>
67+
<include name="jre/lib/ext/jaccess.jar"/>
68+
<include name="jre/lib/ext/jfxrt.jar"/>
69+
<include name="jre/lib/ext/localedata.jar"/>
70+
<include name="jre/lib/ext/nashorn.jar"/>
71+
<include name="jre/lib/ext/sunec.jar"/>
72+
<include name="jre/lib/ext/sunjce_provider.jar"/>
73+
<include name="jre/lib/ext/sunpkcs11.jar"/>
74+
<include name="jre/lib/ext/zipfs.jar"/>
75+
<include name="jre/lib/javaws.jar"/>
76+
<include name="jre/lib/jce.jar"/>
77+
<include name="jre/lib/jfr.jar"/>
78+
<include name="jre/lib/jfxswt.jar"/>
79+
<include name="jre/lib/jsse.jar"/>
80+
<include name="jre/lib/management-agent.jar"/>
81+
<include name="jre/lib/plugin.jar"/>
82+
<include name="jre/lib/resources.jar"/>
83+
<include name="jre/lib/rt.jar"/>
84+
<include name="lib/ant-javafx.jar"/>
85+
<include name="lib/dt.jar"/>
86+
<include name="lib/javafx-mx.jar"/>
87+
<include name="lib/jconsole.jar"/>
88+
<include name="lib/packager.jar"/>
89+
<include name="lib/sa-jdi.jar"/>
90+
<include name="lib/tools.jar"/>
91+
</fileset>
92+
</path>
93+
94+
<property name="project.jdk.home" value="${jdk.home.1.8}"/>
95+
<property name="project.jdk.bin" value="${jdk.bin.1.8}"/>
96+
<property name="project.jdk.classpath" value="jdk.classpath.1.8"/>
97+
98+
<!-- Modules -->
99+
100+
101+
<!-- Module cs-hello-world-lab -->
102+
103+
<dirname property="module.cs-hello-world-lab.basedir" file="${ant.file}"/>
104+
105+
106+
<property name="module.jdk.home.cs-hello-world-lab" value="${project.jdk.home}"/>
107+
<property name="module.jdk.bin.cs-hello-world-lab" value="${project.jdk.bin}"/>
108+
<property name="module.jdk.classpath.cs-hello-world-lab" value="${project.jdk.classpath}"/>
109+
110+
<property name="compiler.args.cs-hello-world-lab" value="-encoding UTF-8 -source 8 -target 8 ${compiler.args}"/>
111+
112+
<property name="cs-hello-world-lab.output.dir" value="${module.cs-hello-world-lab.basedir}/out/production/cs-hello-world-lab"/>
113+
<property name="cs-hello-world-lab.testoutput.dir" value="${module.cs-hello-world-lab.basedir}/out/test/cs-hello-world-lab"/>
114+
115+
<path id="cs-hello-world-lab.module.bootclasspath">
116+
<!-- Paths to be included in compilation bootclasspath -->
117+
</path>
118+
119+
<path id="cs-hello-world-lab.module.production.classpath">
120+
<path refid="${module.jdk.classpath.cs-hello-world-lab}"/>
121+
<pathelement location="${idea.home}/lib/hamcrest-core-1.3.jar"/>
122+
<pathelement location="${idea.home}/lib/junit-4.12.jar"/>
123+
</path>
124+
125+
<path id="cs-hello-world-lab.runtime.production.module.classpath">
126+
<pathelement location="${cs-hello-world-lab.output.dir}"/>
127+
<pathelement location="${idea.home}/lib/hamcrest-core-1.3.jar"/>
128+
<pathelement location="${idea.home}/lib/junit-4.12.jar"/>
129+
</path>
130+
131+
<path id="cs-hello-world-lab.module.classpath">
132+
<path refid="${module.jdk.classpath.cs-hello-world-lab}"/>
133+
<pathelement location="${cs-hello-world-lab.output.dir}"/>
134+
<pathelement location="${idea.home}/lib/hamcrest-core-1.3.jar"/>
135+
<pathelement location="${idea.home}/lib/junit-4.12.jar"/>
136+
<pathelement location="${idea.home}/lib/hamcrest-core-1.3.jar"/>
137+
<pathelement location="${idea.home}/lib/junit-4.12.jar"/>
138+
</path>
139+
140+
<path id="cs-hello-world-lab.runtime.module.classpath">
141+
<pathelement location="${cs-hello-world-lab.testoutput.dir}"/>
142+
<pathelement location="${cs-hello-world-lab.output.dir}"/>
143+
<pathelement location="${idea.home}/lib/hamcrest-core-1.3.jar"/>
144+
<pathelement location="${idea.home}/lib/junit-4.12.jar"/>
145+
<pathelement location="${idea.home}/lib/hamcrest-core-1.3.jar"/>
146+
<pathelement location="${idea.home}/lib/junit-4.12.jar"/>
147+
</path>
148+
149+
150+
<patternset id="excluded.from.module.cs-hello-world-lab">
151+
<patternset refid="ignored.files"/>
152+
</patternset>
153+
154+
<patternset id="excluded.from.compilation.cs-hello-world-lab">
155+
<patternset refid="excluded.from.module.cs-hello-world-lab"/>
156+
</patternset>
157+
158+
<path id="cs-hello-world-lab.module.sourcepath">
159+
<dirset dir="${module.cs-hello-world-lab.basedir}">
160+
<include name="src"/>
161+
</dirset>
162+
</path>
163+
164+
165+
<target name="compile.module.cs-hello-world-lab" depends="compile.module.cs-hello-world-lab.production,compile.module.cs-hello-world-lab.tests" description="Compile module cs-hello-world-lab"/>
166+
167+
<target name="compile.module.cs-hello-world-lab.production" description="Compile module cs-hello-world-lab; production classes">
168+
<mkdir dir="${cs-hello-world-lab.output.dir}"/>
169+
<javac destdir="${cs-hello-world-lab.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true" executable="${module.jdk.bin.cs-hello-world-lab}/javac" includeantruntime="true">
170+
<compilerarg line="${compiler.args.cs-hello-world-lab}"/>
171+
<bootclasspath refid="cs-hello-world-lab.module.bootclasspath"/>
172+
<classpath refid="cs-hello-world-lab.module.production.classpath"/>
173+
<src refid="cs-hello-world-lab.module.sourcepath"/>
174+
<patternset refid="excluded.from.compilation.cs-hello-world-lab"/>
175+
</javac>
176+
177+
<copy todir="${cs-hello-world-lab.output.dir}">
178+
<fileset dir="${module.cs-hello-world-lab.basedir}/src">
179+
<patternset refid="compiler.resources"/>
180+
<type type="file"/>
181+
</fileset>
182+
</copy>
183+
</target>
184+
185+
<target name="compile.module.cs-hello-world-lab.tests" depends="compile.module.cs-hello-world-lab.production" description="compile module cs-hello-world-lab; test classes" unless="skip.tests"/>
186+
187+
<target name="clean.module.cs-hello-world-lab" description="cleanup module">
188+
<delete dir="${cs-hello-world-lab.output.dir}"/>
189+
<delete dir="${cs-hello-world-lab.testoutput.dir}"/>
190+
</target>
191+
192+
<target name="init" description="Build initialization">
193+
<!-- Perform any build initialization in this target -->
194+
</target>
195+
196+
<target name="test">
197+
<junit>
198+
<classpath>
199+
<pathelement location="${idea.home}/lib/hamcrest-core-1.3.jar"/>
200+
<pathelement location="${idea.home}/lib/junit-4.12.jar"/>
201+
<pathelement location="${cs-hello-world-lab.output.dir}"/>
202+
</classpath>
203+
<formatter type="plain" usefile="false"/>
204+
<test name="com.flatironschool.javacs.MainTest" todir="./src"/>
205+
</junit>
206+
</target>
207+
208+
<target name="clean" depends="clean.module.cs-hello-world-lab" description="cleanup all"/>
209+
210+
<target name="build.modules" depends="clean, compile.module.cs-hello-world-lab, test" description="build all modules"/>
211+
212+
<target name="all" depends="build.modules" description="build all"/>
213+
</project>
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.flatironschool.javacs;
2+
3+
public class Main {
4+
public static Double getVersion() {
5+
return Double.parseDouble(System.getProperty("java.specification.version"));
6+
}
7+
8+
public static void main(String[] args) {
9+
// your code here
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.flatironschool.javacs;
2+
3+
import static org.junit.Assert.assertTrue;
4+
5+
/**
6+
* Created by pletcher on 3/10/16.
7+
*/
8+
public class MainTest {
9+
10+
@org.junit.Test
11+
public void testGetVersion() throws Exception {
12+
Main main = new Main();
13+
assertTrue(main.getVersion() >= 1.7);
14+
}
15+
}

0 commit comments

Comments
 (0)