diff --git a/Bits/bits.shadow b/Bits/bits.shadow new file mode 100644 index 0000000..cc3de13 --- /dev/null +++ b/Bits/bits.shadow @@ -0,0 +1,63 @@ +import shadow:io@Console; + +class bits +{ + public main( String[] args ) => () + { + String temp; + Console con; + + con.print("\nEnter an Integer: "); + (temp, ) = con.readLine(); + con.printLine(); + int num = temp.toInt(); + + con.print("Do you want to set, unset, or flip a bit? (s, u, f): "); + (temp, ) = con.readLine(); + con.printLine(); + code choice = temp->codes[0]; + + con.print("Which bit? (0-31): "); + (temp, ) = con.readLine(); + con.printLine(); + int bit = temp.toInt(); + + if(choice == 's') + bitset(num, bit); + + else if(choice == 'u') + unset(num, bit); + + else if(choice == 'f') + flip(num, bit); + } + + public bitset(int num, int bit) => () + { + Console con; + + int temp = 1 << bit; + int new = temp | value; + con.printLine("The result of setting bit " # bit # " in " # num # " is " # new # ".\n"); + + } + + public unset(int num, int bit) => () + { + Console con; + + int temp = 1 << bit; + temp = ~temp; + int new = temp & value; + con.printLine("The result of unsetting bit " # bit # " in " # num # " is " # new # ".\n"); + } + + public flip(int num, int bit) => () + { + Console con; + + int temp = 1 << bit; + int new = temp ^ value; + con.printLine("The result of unsetting bit " # bit # " in " # num # " is " # new # ".\n"); + } +} diff --git a/Concatenation/Concatenation.shadow b/Concatenation/Concatenation.shadow new file mode 100644 index 0000000..f22f85a --- /dev/null +++ b/Concatenation/Concatenation.shadow @@ -0,0 +1,16 @@ +import shadow:io@Console; + +class Concatenation +{ + public main( String[] args ) => () + { + Console con; + + String count; + + count = "One, " # 2 # ", Three, " # 2 + 2 # ", Five, " # 1 + 5 # ", Seven, " # 6 + 2 # ", Nine, " # 7 + 3; + + con.printLine("\nLet's count from 1 to " # 4 + 6 # "!\n"); + con.printLine(count # "\n" ); + } +} diff --git a/HelloWorld/HelloWorld.shadow b/HelloWorld/HelloWorld.shadow index 157730e..66dfa38 100644 --- a/HelloWorld/HelloWorld.shadow +++ b/HelloWorld/HelloWorld.shadow @@ -5,6 +5,8 @@ class HelloWorld { public main( String[] args ) => () { - Console:instance.printLine("Hello, World!"); + Console con; + + con.printLine("Hello, World!"); } } \ No newline at end of file diff --git a/Input Output/InputOutput.shadow b/Input Output/InputOutput.shadow index 2666410..736ce65 100644 --- a/Input Output/InputOutput.shadow +++ b/Input Output/InputOutput.shadow @@ -4,7 +4,7 @@ class InputOutput { public main( String[] args ) => () { - Console con = Console:instance; + Console con; String name, school, home, temp; int age; diff --git a/Multiple Return Values/MultipleReturns.shadow b/Multiple Return Values/MultipleReturns.shadow index 0996ccd..3e21b29 100644 --- a/Multiple Return Values/MultipleReturns.shadow +++ b/Multiple Return Values/MultipleReturns.shadow @@ -4,7 +4,7 @@ class MultipleReturns { public main( String[] args ) => () { - Console con = Console:instance; + Console con; String temp, evenOdd; int num, squared, half, doubled, factorial; diff --git a/loops/Loops1.shadow b/loops/Loops1.shadow index a0a24ac..b65dbc5 100644 --- a/loops/Loops1.shadow +++ b/loops/Loops1.shadow @@ -4,14 +4,15 @@ class Loops1 { public main( String[] args ) => () { + Console con; // print out all the agruments passed to this program foreach(var i in args) { - Console:instance.printLine("Here's the args: " # i); + con.printLine("Here's the args: " # i); } int[,] multi = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; - foreach(int a in multi) { - Console:instance.printLine("Here's the numbers: " # i); + foreach(int i in multi) { + con.printLine("Here's the numbers: " # i); } } -} \ No newline at end of file +}