initial commit
This commit is contained in:
25 files changed
+918
No files matched your search
@@ -0,0 +1,23 @@
|
||||
package lab1;
|
||||
|
||||
/**
|
||||
* Birds demos concatonation.
|
||||
* @author Braeden Sowinski
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class Birds {
|
||||
|
||||
/**
|
||||
* main program entry.
|
||||
* @param args unused
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// defining these as constants due to checkstyle :(
|
||||
final int ten = 10;
|
||||
final int three = 3;
|
||||
System.out.println("Ten robins plus "
|
||||
+ (ten + three)
|
||||
+ " canaries is 23 birds."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package lab1;
|
||||
|
||||
/**
|
||||
* This program prints out 1 to 5 in three languages.
|
||||
* @author = Braeden Sowinski
|
||||
* @version = 1.0.0
|
||||
*/
|
||||
public class Count {
|
||||
|
||||
// below is a javadoc comment, its different from multi line by
|
||||
// starting with two stars
|
||||
/**
|
||||
* main program entry.
|
||||
* @param args unused
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// Here is 1 to 5 in English
|
||||
System.out.println("One, two, three, four, five.");
|
||||
|
||||
// Here is 1 to 5 in French
|
||||
System.out.println("Un, deux, trois, quatre, cinq.");
|
||||
|
||||
// Here is 1 to 5 in Spanish
|
||||
System.out.println("Uno, dos, tres, cuatro, cinco");
|
||||
}
|
||||
}
|
||||
|
||||
// removing one slash from the beginning of the comment makes it invalid
|
||||
// adding slashes after the first two initial slashes is ok. they are ignored
|
||||
|
||||
/*
|
||||
* this is a multi-line comment
|
||||
*/
|
||||
@@ -0,0 +1,38 @@
|
||||
package lab1;
|
||||
|
||||
/**
|
||||
* Prints hello world message.
|
||||
* @author Braeden Sowinski
|
||||
* @version 1.0.0
|
||||
* */
|
||||
public class Hello {
|
||||
|
||||
/**
|
||||
* main program entry.
|
||||
* @param args unused
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* After changing the classname to "helo", the error is:
|
||||
* Error: Could not find or load main class lab1.Hello in module lab0
|
||||
*
|
||||
* Changing the text inside of the println function produces no errors and
|
||||
* simply outputs "Helo World!" as intended.
|
||||
*
|
||||
* Removing the final quotation produces the error:
|
||||
* String literal is not properly closed by a double-quote
|
||||
*
|
||||
* Removing the first quotation produces the error:
|
||||
* Syntax error on token(s), misplaced construct(s)
|
||||
* Syntax error on token "!", ; expected
|
||||
* String literal is not properly closed by a double-quote
|
||||
*
|
||||
* Forgetting a semi-colon at the end of a line of code will produce a
|
||||
* syntax error:
|
||||
* "Syntax error, insert ";" to complete BlockStatements"
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,28 @@
|
||||
package lab1;
|
||||
|
||||
/**
|
||||
* Plus demonstrates the different behaviours of the + operator.
|
||||
* @author Braeden Sowinski
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class Plus {
|
||||
/**
|
||||
* main program entry.
|
||||
* @param args unused
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println("This is a long string that is the"
|
||||
+ " concatenation of two shorter strings.");
|
||||
|
||||
final int years = 70;
|
||||
|
||||
System.out.println("The first computer was invented about "
|
||||
+ years + " years ago");
|
||||
|
||||
final int num1 = 8;
|
||||
final int num2 = 5;
|
||||
System.out.println("8 plus 5 is " + num1 + num2);
|
||||
System.out.println("8 plus 5 is " + (num1 + num2));
|
||||
System.out.println(num1 + num2 + " equals 8 plus 5.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package lab1;
|
||||
|
||||
/**
|
||||
* Poem prints a poem.
|
||||
* @author Braeden Sowinski
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class Poem {
|
||||
|
||||
/**
|
||||
* main program entry.
|
||||
* @param args unused
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Roses are red");
|
||||
System.out.println("Violets are blue");
|
||||
System.out.println("Sugar is sweet");
|
||||
System.out.println("But I have commitment issues");
|
||||
System.out.println("So I'd rather just be friends");
|
||||
System.out.println("At this point in our relationship.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package lab1;
|
||||
|
||||
/**
|
||||
* Problems contains problems to fix.
|
||||
* @author Braeden Sowinski
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class Problems {
|
||||
|
||||
/**
|
||||
* main program entry.
|
||||
* @param args unused
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
System.out.println("This program used to have lots ofproblems,");
|
||||
System.out.println("but if it prints this, you fixed them all.");
|
||||
System.out.println(" *** Hurray! ***");
|
||||
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
}
|
||||
}
|
||||
|
||||
// All problems have been fixed
|
||||
@@ -0,0 +1,27 @@
|
||||
package lab1;
|
||||
|
||||
/**
|
||||
* Simple talk about valid variable identifiers.
|
||||
* @author Braeden Sowinski
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class Simple {
|
||||
|
||||
/**
|
||||
* main program entry.
|
||||
* @param args unused
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.print("I love Java!\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* simple - invalid, cannot match class name
|
||||
* SimpleProgram - valid
|
||||
* 1_Simple - invalid, cannot start with a number
|
||||
* _simple_ - valid
|
||||
* *Simple* - invalid, contains invalid characters (*)
|
||||
* $123_45 - valid
|
||||
* Simple! - invalid, contains an invalid character (!)
|
||||
*/
|
||||
Reference in new issue
Block a user