diff --git a/.vscode/settings.json b/.vscode/settings.json index 7b016a8..d53ecaf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "java.compile.nullAnalysis.mode": "automatic" + "java.compile.nullAnalysis.mode": "automatic", + "java.configuration.updateBuildConfiguration": "automatic" } \ No newline at end of file diff --git a/week1_TinsaeGhilay/.gitignore b/week1_TinsaeGhilay/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/week1_TinsaeGhilay/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/week1_TinsaeGhilay/.zed/debug.json b/week1_TinsaeGhilay/.zed/debug.json new file mode 100644 index 0000000..e61eb78 --- /dev/null +++ b/week1_TinsaeGhilay/.zed/debug.json @@ -0,0 +1,18 @@ +// Project-local debug tasks +// +// For more documentation on how to configure debug tasks, +// see: https://zed.dev/docs/debugger +[ + { + "adapter": "Java", + "request": "launch", + "label": "Launch Debugger", + // if your project has multiple entry points, specify the one to use: + // "mainClass": "com.myorganization.myproject.MyMainClass", + // + // this effectively sets a breakpoint at your program entry: + "stopOnEntry": true, + // the working directory for the debug process + "cwd": "$ZED_WORKTREE_ROOT" + } +] diff --git a/week1_TinsaeGhilay/.zed/tasks.json b/week1_TinsaeGhilay/.zed/tasks.json new file mode 100644 index 0000000..e69de29 diff --git a/week1_TinsaeGhilay/Greeter.class b/week1_TinsaeGhilay/Greeter.class new file mode 100644 index 0000000..71e0ffa Binary files /dev/null and b/week1_TinsaeGhilay/Greeter.class differ diff --git a/week1_TinsaeGhilay/Main.class b/week1_TinsaeGhilay/Main.class new file mode 100644 index 0000000..7aa9b92 Binary files /dev/null and b/week1_TinsaeGhilay/Main.class differ diff --git a/week1_TinsaeGhilay/Main.java b/week1_TinsaeGhilay/Main.java new file mode 100644 index 0000000..0af2c8c --- /dev/null +++ b/week1_TinsaeGhilay/Main.java @@ -0,0 +1,62 @@ +import java.io.*; + +public class Main { + + public static void main(String[] args) { + System.out.println("Hello world. This is a demo of Greeter"); + // I think I hate me + Greeter greeter = new Greeter("Fuck you"); + greeter.greet(); + } +} + +class Greeter { + + String message; + + // default message + public Greeter(String message) { + this.message = message; + } + + // greet + public void greet() { + this.message = getUserInput("What's your message?"); + String name = getUserInput("Who do you want to say that to?"); + + // if no message, we heve nothing to relay + if(this.message == null){ + System.out.println("No messege to relay"); + return; + } + + // if no name, we have no name to relay massage to + if(name == null){ + System.out.println("No name to relay message to"); + return; + } + + // else we print message + System.out.println(message + "! " + name); + } + + // get user input + private String getUserInput(String prompt) { + System.out.print(prompt + ": "); + + try { + String input = ""; + int i; + while ((i = System.in.read()) != '\n') { + input = input + (char) i; + } + if (!input.isEmpty()) { + return input; + } + } catch (IOException e) { + System.err.println("Error reading input"); + } + + return null; + } +} diff --git a/week1_TinsaeGhilay/Task1/Hello.idl b/week1_TinsaeGhilay/Task1/Hello.idl new file mode 100644 index 0000000..60154f9 --- /dev/null +++ b/week1_TinsaeGhilay/Task1/Hello.idl @@ -0,0 +1,8 @@ +module HelloApp +{ + interface Hello + { + string sayHello(); + oneway void shutdown(); + }; +}; diff --git a/week1_TinsaeGhilay/Task1/HelloApp/Hello.class b/week1_TinsaeGhilay/Task1/HelloApp/Hello.class new file mode 100644 index 0000000..7baf6eb Binary files /dev/null and b/week1_TinsaeGhilay/Task1/HelloApp/Hello.class differ diff --git a/week1_TinsaeGhilay/Task1/HelloApp/Hello.java b/week1_TinsaeGhilay/Task1/HelloApp/Hello.java new file mode 100644 index 0000000..5dc4d79 --- /dev/null +++ b/week1_TinsaeGhilay/Task1/HelloApp/Hello.java @@ -0,0 +1,13 @@ +package HelloApp; + + +/** +* HelloApp/Hello.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Hello.idl +* Sunday, November 9, 2025 2:43:24 PM CET +*/ + +public interface Hello extends HelloOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity +{ +} // interface Hello diff --git a/week1_TinsaeGhilay/Task1/HelloApp/HelloHelper.class b/week1_TinsaeGhilay/Task1/HelloApp/HelloHelper.class new file mode 100644 index 0000000..4dbdb75 Binary files /dev/null and b/week1_TinsaeGhilay/Task1/HelloApp/HelloHelper.class differ diff --git a/week1_TinsaeGhilay/Task1/HelloApp/HelloHelper.java b/week1_TinsaeGhilay/Task1/HelloApp/HelloHelper.java new file mode 100644 index 0000000..f6c532e --- /dev/null +++ b/week1_TinsaeGhilay/Task1/HelloApp/HelloHelper.java @@ -0,0 +1,85 @@ +package HelloApp; + + +/** +* HelloApp/HelloHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Hello.idl +* Sunday, November 9, 2025 2:43:24 PM CET +*/ + +abstract public class HelloHelper +{ + private static String _id = "IDL:HelloApp/Hello:1.0"; + + public static void insert (org.omg.CORBA.Any a, HelloApp.Hello that) + { + org.omg.CORBA.portable.OutputStream out = a.create_output_stream (); + a.type (type ()); + write (out, that); + a.read_value (out.create_input_stream (), type ()); + } + + public static HelloApp.Hello extract (org.omg.CORBA.Any a) + { + return read (a.create_input_stream ()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + synchronized public static org.omg.CORBA.TypeCode type () + { + if (__typeCode == null) + { + __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (HelloApp.HelloHelper.id (), "Hello"); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static HelloApp.Hello read (org.omg.CORBA.portable.InputStream istream) + { + return narrow (istream.read_Object (_HelloStub.class)); + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, HelloApp.Hello value) + { + ostream.write_Object ((org.omg.CORBA.Object) value); + } + + public static HelloApp.Hello narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof HelloApp.Hello) + return (HelloApp.Hello)obj; + else if (!obj._is_a (id ())) + throw new org.omg.CORBA.BAD_PARAM (); + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + HelloApp._HelloStub stub = new HelloApp._HelloStub (); + stub._set_delegate(delegate); + return stub; + } + } + + public static HelloApp.Hello unchecked_narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof HelloApp.Hello) + return (HelloApp.Hello)obj; + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + HelloApp._HelloStub stub = new HelloApp._HelloStub (); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/week1_TinsaeGhilay/Task1/HelloApp/HelloHolder.class b/week1_TinsaeGhilay/Task1/HelloApp/HelloHolder.class new file mode 100644 index 0000000..920da41 Binary files /dev/null and b/week1_TinsaeGhilay/Task1/HelloApp/HelloHolder.class differ diff --git a/week1_TinsaeGhilay/Task1/HelloApp/HelloHolder.java b/week1_TinsaeGhilay/Task1/HelloApp/HelloHolder.java new file mode 100644 index 0000000..90bc9ba --- /dev/null +++ b/week1_TinsaeGhilay/Task1/HelloApp/HelloHolder.java @@ -0,0 +1,38 @@ +package HelloApp; + +/** +* HelloApp/HelloHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Hello.idl +* Sunday, November 9, 2025 2:43:24 PM CET +*/ + +public final class HelloHolder implements org.omg.CORBA.portable.Streamable +{ + public HelloApp.Hello value = null; + + public HelloHolder () + { + } + + public HelloHolder (HelloApp.Hello initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = HelloApp.HelloHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + HelloApp.HelloHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return HelloApp.HelloHelper.type (); + } + +} diff --git a/week1_TinsaeGhilay/Task1/HelloApp/HelloOperations.class b/week1_TinsaeGhilay/Task1/HelloApp/HelloOperations.class new file mode 100644 index 0000000..9e5c4a2 Binary files /dev/null and b/week1_TinsaeGhilay/Task1/HelloApp/HelloOperations.class differ diff --git a/week1_TinsaeGhilay/Task1/HelloApp/HelloOperations.java b/week1_TinsaeGhilay/Task1/HelloApp/HelloOperations.java new file mode 100644 index 0000000..802b39d --- /dev/null +++ b/week1_TinsaeGhilay/Task1/HelloApp/HelloOperations.java @@ -0,0 +1,15 @@ +package HelloApp; + + +/** +* HelloApp/HelloOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Hello.idl +* Sunday, November 9, 2025 2:43:24 PM CET +*/ + +public interface HelloOperations +{ + String sayHello (); + void shutdown (); +} // interface HelloOperations diff --git a/week1_TinsaeGhilay/Task1/HelloApp/HelloPOA.class b/week1_TinsaeGhilay/Task1/HelloApp/HelloPOA.class new file mode 100644 index 0000000..52af8b2 Binary files /dev/null and b/week1_TinsaeGhilay/Task1/HelloApp/HelloPOA.class differ diff --git a/week1_TinsaeGhilay/Task1/HelloApp/HelloPOA.java b/week1_TinsaeGhilay/Task1/HelloApp/HelloPOA.java new file mode 100644 index 0000000..c3a5120 --- /dev/null +++ b/week1_TinsaeGhilay/Task1/HelloApp/HelloPOA.java @@ -0,0 +1,80 @@ +package HelloApp; + + +/** +* HelloApp/HelloPOA.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Hello.idl +* Sunday, November 9, 2025 2:43:24 PM CET +*/ + +public abstract class HelloPOA extends org.omg.PortableServer.Servant + implements HelloApp.HelloOperations, org.omg.CORBA.portable.InvokeHandler +{ + + // Constructors + + private static java.util.Hashtable _methods = new java.util.Hashtable (); + static + { + _methods.put ("sayHello", new java.lang.Integer (0)); + _methods.put ("shutdown", new java.lang.Integer (1)); + } + + public org.omg.CORBA.portable.OutputStream _invoke (String $method, + org.omg.CORBA.portable.InputStream in, + org.omg.CORBA.portable.ResponseHandler $rh) + { + org.omg.CORBA.portable.OutputStream out = null; + java.lang.Integer __method = (java.lang.Integer)_methods.get ($method); + if (__method == null) + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + + switch (__method.intValue ()) + { + case 0: // HelloApp/Hello/sayHello + { + String $result = null; + $result = this.sayHello (); + out = $rh.createReply(); + out.write_string ($result); + break; + } + + case 1: // HelloApp/Hello/shutdown + { + this.shutdown (); + out = $rh.createReply(); + break; + } + + default: + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + } + + return out; + } // _invoke + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:HelloApp/Hello:1.0"}; + + public String[] _all_interfaces (org.omg.PortableServer.POA poa, byte[] objectId) + { + return (String[])__ids.clone (); + } + + public Hello _this() + { + return HelloHelper.narrow( + super._this_object()); + } + + public Hello _this(org.omg.CORBA.ORB orb) + { + return HelloHelper.narrow( + super._this_object(orb)); + } + + +} // class HelloPOA diff --git a/week1_TinsaeGhilay/Task1/HelloApp/_HelloStub.class b/week1_TinsaeGhilay/Task1/HelloApp/_HelloStub.class new file mode 100644 index 0000000..71e85ce Binary files /dev/null and b/week1_TinsaeGhilay/Task1/HelloApp/_HelloStub.class differ diff --git a/week1_TinsaeGhilay/Task1/HelloApp/_HelloStub.java b/week1_TinsaeGhilay/Task1/HelloApp/_HelloStub.java new file mode 100644 index 0000000..52b0d58 --- /dev/null +++ b/week1_TinsaeGhilay/Task1/HelloApp/_HelloStub.java @@ -0,0 +1,88 @@ +package HelloApp; + + +/** +* HelloApp/_HelloStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Hello.idl +* Sunday, November 9, 2025 2:43:24 PM CET +*/ + +public class _HelloStub extends org.omg.CORBA.portable.ObjectImpl implements HelloApp.Hello +{ + + public String sayHello () + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("sayHello", true); + $in = _invoke ($out); + String $result = $in.read_string (); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return sayHello ( ); + } finally { + _releaseReply ($in); + } + } // sayHello + + public void shutdown () + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("shutdown", false); + $in = _invoke ($out); + return; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + shutdown ( ); + } finally { + _releaseReply ($in); + } + } // shutdown + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:HelloApp/Hello:1.0"}; + + public String[] _ids () + { + return (String[])__ids.clone (); + } + + private void readObject (java.io.ObjectInputStream s) throws java.io.IOException + { + String str = s.readUTF (); + com.sun.corba.se.impl.orbutil.IORCheckImpl.check(str, "HelloApp._HelloStub"); + String[] args = null; + java.util.Properties props = null; + org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props); + try { + org.omg.CORBA.Object obj = orb.string_to_object (str); + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate (); + _set_delegate (delegate); + } finally { + orb.destroy() ; + } + } + + private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException + { + String[] args = null; + java.util.Properties props = null; + org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props); + try { + String str = orb.object_to_string (this); + s.writeUTF (str); + } finally { + orb.destroy() ; + } + } +} // class _HelloStub diff --git a/week1_TinsaeGhilay/Task1/HelloClient.class b/week1_TinsaeGhilay/Task1/HelloClient.class new file mode 100644 index 0000000..741cbf4 Binary files /dev/null and b/week1_TinsaeGhilay/Task1/HelloClient.class differ diff --git a/week1_TinsaeGhilay/Task1/HelloClient.java b/week1_TinsaeGhilay/Task1/HelloClient.java new file mode 100644 index 0000000..2c981a4 --- /dev/null +++ b/week1_TinsaeGhilay/Task1/HelloClient.java @@ -0,0 +1,38 @@ +// Copyright and License + +import HelloApp.*; +import org.omg.CORBA.*; +import org.omg.CosNaming.*; + +public class HelloClient { + + static Hello helloImpl; + + public static void main(String args[]) { + try { + // create and initialize the ORB + ORB orb = ORB.init(args, null); + + // get the root naming context + org.omg.CORBA.Object objRef = orb.resolve_initial_references( + "NameService" + ); + // Use NamingContextExt instead of NamingContext. This is + // part of the Interoperable naming Service. + NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); + + // resolve the Object Reference in Naming + String name = "Hello"; + helloImpl = HelloHelper.narrow(ncRef.resolve_str(name)); + + System.out.println( + "Obtained a handle on server object: " + helloImpl + ); + System.out.println(helloImpl.sayHello()); + helloImpl.shutdown(); + } catch (Exception e) { + System.out.println("ERROR : " + e); + e.printStackTrace(System.out); + } + } +} diff --git a/week1_TinsaeGhilay/Task1/HelloImpl.class b/week1_TinsaeGhilay/Task1/HelloImpl.class new file mode 100644 index 0000000..5d21a8c Binary files /dev/null and b/week1_TinsaeGhilay/Task1/HelloImpl.class differ diff --git a/week1_TinsaeGhilay/Task1/HelloServer.class b/week1_TinsaeGhilay/Task1/HelloServer.class new file mode 100644 index 0000000..0f91a9a Binary files /dev/null and b/week1_TinsaeGhilay/Task1/HelloServer.class differ diff --git a/week1_TinsaeGhilay/Task1/HelloServer.java b/week1_TinsaeGhilay/Task1/HelloServer.java new file mode 100644 index 0000000..4566888 --- /dev/null +++ b/week1_TinsaeGhilay/Task1/HelloServer.java @@ -0,0 +1,73 @@ +// HelloServer.java +import HelloApp.*; +import org.omg.CosNaming.*; +import org.omg.CORBA.*; +import org.omg.PortableServer.*; +import org.omg.PortableServer.POA; + + +class HelloImpl extends HelloPOA { + private ORB orb; + + public void setORB(ORB orb_val) { + orb = orb_val; + } + + // implement sayHello() method + public String sayHello() { + return "\nHello world !!\n"; + } + + // implement shutdown() method + public void shutdown() { + orb.shutdown(false); + } +} + + +public class HelloServer { + + public static void main(String args[]) { + try{ + // create and initialize the ORB + ORB orb = ORB.init(args, null); + + // get reference to rootpoa and activate the POAManager + POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); + rootpoa.the_POAManager().activate(); + + // create servant and register it with the ORB + HelloImpl helloImpl = new HelloImpl(); + helloImpl.setORB(orb); + + // get object reference from the servant + org.omg.CORBA.Object ref = rootpoa.servant_to_reference(helloImpl); + Hello href = HelloHelper.narrow(ref); + + // get the root naming context + org.omg.CORBA.Object objRef = + orb.resolve_initial_references("NameService"); + // Use NamingContextExt which is part of the Interoperable + // Naming Service (INS) specification. + NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); + + // bind the Object Reference in Naming + String name = "Hello"; + NameComponent path[] = ncRef.to_name( name ); + ncRef.rebind(path, href); + + System.out.println("HelloServer ready and waiting ..."); + + // wait for invocations from clients + orb.run(); + } + + catch (Exception e) { + System.err.println("ERROR: " + e); + e.printStackTrace(System.out); + } + + System.out.println("HelloServer Exiting ..."); + + } +} diff --git a/week1_TinsaeGhilay/Task2/Graph.class b/week1_TinsaeGhilay/Task2/Graph.class new file mode 100644 index 0000000..db45f0e Binary files /dev/null and b/week1_TinsaeGhilay/Task2/Graph.class differ diff --git a/week1_TinsaeGhilay/Task2/Graphics.idl b/week1_TinsaeGhilay/Task2/Graphics.idl new file mode 100644 index 0000000..3a848fb --- /dev/null +++ b/week1_TinsaeGhilay/Task2/Graphics.idl @@ -0,0 +1,53 @@ +// task 2. + + + +// module +module GraphicsApp +{ + // forward declaration of shape. + // because we use it in rectangle + interface GraphicalObject; + + typedef sequence ObjectSequence; + + // rectangle contains shapes which GraphicalObjects a + interface Rectangle + { + + // exception to be thrown if index out of range + exception IndexOutOfBounds {}; + + // hopping this will be an array of Graphical-objects. + attribute ObjectSequence objects; + + // function to add object + void addObject(in GraphicalObject newShape); + + // and may be remove an object from a position? + void removeObjectAtPosition(in unsigned long index) + raises (IndexOutOfBounds); + }; + + interface Shape + { + // draw to be overriden in java + void draw(); + + // and info + void showInfo(); + }; + + // GraphicalShape object extends Shape + interface GraphicalObject : Shape + { + // unqualified member + attribute boolean is_filled; + + // we cannot set this, so only getter will be implemented. + // only time a shape can change is if it's in the matrix or if Dr.Strange is in town. + readonly attribute string name; + }; + + +}; diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObject.class b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObject.class new file mode 100644 index 0000000..b6ea114 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObject.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObject.java b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObject.java new file mode 100644 index 0000000..69b75fe --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObject.java @@ -0,0 +1,15 @@ +package GraphicsApp; + + +/** +* GraphicsApp/GraphicalObject.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// GraphicalShape object extends Shape +public interface GraphicalObject extends GraphicalObjectOperations, GraphicsApp.Shape, org.omg.CORBA.portable.IDLEntity +{ +} // interface GraphicalObject diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHelper.class b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHelper.class new file mode 100644 index 0000000..bb2ca9e Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHelper.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHelper.java b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHelper.java new file mode 100644 index 0000000..6eee4eb --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHelper.java @@ -0,0 +1,87 @@ +package GraphicsApp; + + +/** +* GraphicsApp/GraphicalObjectHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// GraphicalShape object extends Shape +abstract public class GraphicalObjectHelper +{ + private static String _id = "IDL:GraphicsApp/GraphicalObject:1.0"; + + public static void insert (org.omg.CORBA.Any a, GraphicsApp.GraphicalObject that) + { + org.omg.CORBA.portable.OutputStream out = a.create_output_stream (); + a.type (type ()); + write (out, that); + a.read_value (out.create_input_stream (), type ()); + } + + public static GraphicsApp.GraphicalObject extract (org.omg.CORBA.Any a) + { + return read (a.create_input_stream ()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + synchronized public static org.omg.CORBA.TypeCode type () + { + if (__typeCode == null) + { + __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (GraphicsApp.GraphicalObjectHelper.id (), "GraphicalObject"); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static GraphicsApp.GraphicalObject read (org.omg.CORBA.portable.InputStream istream) + { + return narrow (istream.read_Object (_GraphicalObjectStub.class)); + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, GraphicsApp.GraphicalObject value) + { + ostream.write_Object ((org.omg.CORBA.Object) value); + } + + public static GraphicsApp.GraphicalObject narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof GraphicsApp.GraphicalObject) + return (GraphicsApp.GraphicalObject)obj; + else if (!obj._is_a (id ())) + throw new org.omg.CORBA.BAD_PARAM (); + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + GraphicsApp._GraphicalObjectStub stub = new GraphicsApp._GraphicalObjectStub (); + stub._set_delegate(delegate); + return stub; + } + } + + public static GraphicsApp.GraphicalObject unchecked_narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof GraphicsApp.GraphicalObject) + return (GraphicsApp.GraphicalObject)obj; + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + GraphicsApp._GraphicalObjectStub stub = new GraphicsApp._GraphicalObjectStub (); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHolder.class b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHolder.class new file mode 100644 index 0000000..69eabbb Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHolder.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHolder.java b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHolder.java new file mode 100644 index 0000000..691e4df --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectHolder.java @@ -0,0 +1,40 @@ +package GraphicsApp; + +/** +* GraphicsApp/GraphicalObjectHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// GraphicalShape object extends Shape +public final class GraphicalObjectHolder implements org.omg.CORBA.portable.Streamable +{ + public GraphicsApp.GraphicalObject value = null; + + public GraphicalObjectHolder () + { + } + + public GraphicalObjectHolder (GraphicsApp.GraphicalObject initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = GraphicsApp.GraphicalObjectHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + GraphicsApp.GraphicalObjectHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return GraphicsApp.GraphicalObjectHelper.type (); + } + +} diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectOperations.class b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectOperations.class new file mode 100644 index 0000000..c7b93a5 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectOperations.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectOperations.java b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectOperations.java new file mode 100644 index 0000000..426c3cd --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectOperations.java @@ -0,0 +1,24 @@ +package GraphicsApp; + + +/** +* GraphicsApp/GraphicalObjectOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// GraphicalShape object extends Shape +public interface GraphicalObjectOperations extends GraphicsApp.ShapeOperations +{ + + // unqualified member + boolean is_filled (); + + // unqualified member + void is_filled (boolean newIs_filled); + + // only time a shape can change is if it's in the matrix or if Dr.Strange is in town. + String name (); +} // interface GraphicalObjectOperations diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectPOA.class b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectPOA.class new file mode 100644 index 0000000..ef9c06d Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectPOA.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectPOA.java b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectPOA.java new file mode 100644 index 0000000..c259a98 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/GraphicalObjectPOA.java @@ -0,0 +1,120 @@ +package GraphicsApp; + + +/** +* GraphicsApp/GraphicalObjectPOA.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// GraphicalShape object extends Shape +public abstract class GraphicalObjectPOA extends org.omg.PortableServer.Servant + implements GraphicsApp.GraphicalObjectOperations, org.omg.CORBA.portable.InvokeHandler +{ + + // Constructors + + private static java.util.Hashtable _methods = new java.util.Hashtable (); + static + { + _methods.put ("_get_is_filled", new java.lang.Integer (0)); + _methods.put ("_set_is_filled", new java.lang.Integer (1)); + _methods.put ("_get_name", new java.lang.Integer (2)); + _methods.put ("draw", new java.lang.Integer (3)); + _methods.put ("showInfo", new java.lang.Integer (4)); + } + + public org.omg.CORBA.portable.OutputStream _invoke (String $method, + org.omg.CORBA.portable.InputStream in, + org.omg.CORBA.portable.ResponseHandler $rh) + { + org.omg.CORBA.portable.OutputStream out = null; + java.lang.Integer __method = (java.lang.Integer)_methods.get ($method); + if (__method == null) + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + + switch (__method.intValue ()) + { + + // unqualified member + case 0: // GraphicsApp/GraphicalObject/_get_is_filled + { + boolean $result = false; + $result = this.is_filled (); + out = $rh.createReply(); + out.write_boolean ($result); + break; + } + + + // unqualified member + case 1: // GraphicsApp/GraphicalObject/_set_is_filled + { + boolean newIs_filled = in.read_boolean (); + this.is_filled (newIs_filled); + out = $rh.createReply(); + break; + } + + + // only time a shape can change is if it's in the matrix or if Dr.Strange is in town. + case 2: // GraphicsApp/GraphicalObject/_get_name + { + String $result = null; + $result = this.name (); + out = $rh.createReply(); + out.write_string ($result); + break; + } + + + // draw to be overriden in java + case 3: // GraphicsApp/Shape/draw + { + this.draw (); + out = $rh.createReply(); + break; + } + + + // and info + case 4: // GraphicsApp/Shape/showInfo + { + this.showInfo (); + out = $rh.createReply(); + break; + } + + default: + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + } + + return out; + } // _invoke + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:GraphicsApp/GraphicalObject:1.0", + "IDL:GraphicsApp/Shape:1.0"}; + + public String[] _all_interfaces (org.omg.PortableServer.POA poa, byte[] objectId) + { + return (String[])__ids.clone (); + } + + public GraphicalObject _this() + { + return GraphicalObjectHelper.narrow( + super._this_object()); + } + + public GraphicalObject _this(org.omg.CORBA.ORB orb) + { + return GraphicalObjectHelper.narrow( + super._this_object(orb)); + } + + +} // class GraphicalObjectPOA diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHelper.class b/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHelper.class new file mode 100644 index 0000000..6899cc9 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHelper.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHelper.java b/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHelper.java new file mode 100644 index 0000000..d0b252f --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHelper.java @@ -0,0 +1,62 @@ +package GraphicsApp; + + +/** +* GraphicsApp/ObjectSequenceHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + +abstract public class ObjectSequenceHelper +{ + private static String _id = "IDL:GraphicsApp/ObjectSequence:1.0"; + + public static void insert (org.omg.CORBA.Any a, GraphicsApp.GraphicalObject[] that) + { + org.omg.CORBA.portable.OutputStream out = a.create_output_stream (); + a.type (type ()); + write (out, that); + a.read_value (out.create_input_stream (), type ()); + } + + public static GraphicsApp.GraphicalObject[] extract (org.omg.CORBA.Any a) + { + return read (a.create_input_stream ()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + synchronized public static org.omg.CORBA.TypeCode type () + { + if (__typeCode == null) + { + __typeCode = GraphicsApp.GraphicalObjectHelper.type (); + __typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode); + __typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (GraphicsApp.ObjectSequenceHelper.id (), "ObjectSequence", __typeCode); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static GraphicsApp.GraphicalObject[] read (org.omg.CORBA.portable.InputStream istream) + { + GraphicsApp.GraphicalObject value[] = null; + int _len0 = istream.read_long (); + value = new GraphicsApp.GraphicalObject[_len0]; + for (int _o1 = 0;_o1 < value.length; ++_o1) + value[_o1] = GraphicsApp.GraphicalObjectHelper.read (istream); + return value; + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, GraphicsApp.GraphicalObject[] value) + { + ostream.write_long (value.length); + for (int _i0 = 0;_i0 < value.length; ++_i0) + GraphicsApp.GraphicalObjectHelper.write (ostream, value[_i0]); + } + +} diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHolder.class b/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHolder.class new file mode 100644 index 0000000..b9f4659 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHolder.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHolder.java b/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHolder.java new file mode 100644 index 0000000..9885fbe --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/ObjectSequenceHolder.java @@ -0,0 +1,39 @@ +package GraphicsApp; + + +/** +* GraphicsApp/ObjectSequenceHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + +public final class ObjectSequenceHolder implements org.omg.CORBA.portable.Streamable +{ + public GraphicsApp.GraphicalObject value[] = null; + + public ObjectSequenceHolder () + { + } + + public ObjectSequenceHolder (GraphicsApp.GraphicalObject[] initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = GraphicsApp.ObjectSequenceHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + GraphicsApp.ObjectSequenceHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return GraphicsApp.ObjectSequenceHelper.type (); + } + +} diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/Rectangle.class b/week1_TinsaeGhilay/Task2/GraphicsApp/Rectangle.class new file mode 100644 index 0000000..2230c95 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/Rectangle.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/Rectangle.java b/week1_TinsaeGhilay/Task2/GraphicsApp/Rectangle.java new file mode 100644 index 0000000..666ca93 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/Rectangle.java @@ -0,0 +1,15 @@ +package GraphicsApp; + + +/** +* GraphicsApp/Rectangle.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// rectangle contains shapes which GraphicalObjects a +public interface Rectangle extends RectangleOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity +{ +} // interface Rectangle diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHelper.class b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHelper.class new file mode 100644 index 0000000..c90711f Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHelper.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHelper.java b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHelper.java new file mode 100644 index 0000000..b8365a3 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHelper.java @@ -0,0 +1,87 @@ +package GraphicsApp; + + +/** +* GraphicsApp/RectangleHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// rectangle contains shapes which GraphicalObjects a +abstract public class RectangleHelper +{ + private static String _id = "IDL:GraphicsApp/Rectangle:1.0"; + + public static void insert (org.omg.CORBA.Any a, GraphicsApp.Rectangle that) + { + org.omg.CORBA.portable.OutputStream out = a.create_output_stream (); + a.type (type ()); + write (out, that); + a.read_value (out.create_input_stream (), type ()); + } + + public static GraphicsApp.Rectangle extract (org.omg.CORBA.Any a) + { + return read (a.create_input_stream ()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + synchronized public static org.omg.CORBA.TypeCode type () + { + if (__typeCode == null) + { + __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (GraphicsApp.RectangleHelper.id (), "Rectangle"); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static GraphicsApp.Rectangle read (org.omg.CORBA.portable.InputStream istream) + { + return narrow (istream.read_Object (_RectangleStub.class)); + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, GraphicsApp.Rectangle value) + { + ostream.write_Object ((org.omg.CORBA.Object) value); + } + + public static GraphicsApp.Rectangle narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof GraphicsApp.Rectangle) + return (GraphicsApp.Rectangle)obj; + else if (!obj._is_a (id ())) + throw new org.omg.CORBA.BAD_PARAM (); + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + GraphicsApp._RectangleStub stub = new GraphicsApp._RectangleStub (); + stub._set_delegate(delegate); + return stub; + } + } + + public static GraphicsApp.Rectangle unchecked_narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof GraphicsApp.Rectangle) + return (GraphicsApp.Rectangle)obj; + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + GraphicsApp._RectangleStub stub = new GraphicsApp._RectangleStub (); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHolder.class b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHolder.class new file mode 100644 index 0000000..7f3eb5a Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHolder.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHolder.java b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHolder.java new file mode 100644 index 0000000..6d10172 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleHolder.java @@ -0,0 +1,40 @@ +package GraphicsApp; + +/** +* GraphicsApp/RectangleHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// rectangle contains shapes which GraphicalObjects a +public final class RectangleHolder implements org.omg.CORBA.portable.Streamable +{ + public GraphicsApp.Rectangle value = null; + + public RectangleHolder () + { + } + + public RectangleHolder (GraphicsApp.Rectangle initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = GraphicsApp.RectangleHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + GraphicsApp.RectangleHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return GraphicsApp.RectangleHelper.type (); + } + +} diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleOperations.class b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleOperations.class new file mode 100644 index 0000000..3718218 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleOperations.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleOperations.java b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleOperations.java new file mode 100644 index 0000000..b2483a9 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/RectangleOperations.java @@ -0,0 +1,27 @@ +package GraphicsApp; + + +/** +* GraphicsApp/RectangleOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// rectangle contains shapes which GraphicalObjects a +public interface RectangleOperations +{ + + // hopping this will be an array of shapes. + GraphicsApp.GraphicalObject[] objects (); + + // hopping this will be an array of shapes. + void objects (GraphicsApp.GraphicalObject[] newObjects); + + // function to add shape + void addObject (GraphicsApp.GraphicalObject newShape); + + // and may be remove a shape from a position? + void removeObjectAtPosition (int index) throws GraphicsApp.RectanglePackage.IndexOutOfBounds; +} // interface RectangleOperations diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePOA.class b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePOA.class new file mode 100644 index 0000000..fe0f146 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePOA.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePOA.java b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePOA.java new file mode 100644 index 0000000..f748ea4 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePOA.java @@ -0,0 +1,114 @@ +package GraphicsApp; + + +/** +* GraphicsApp/RectanglePOA.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// rectangle contains shapes which GraphicalObjects a +public abstract class RectanglePOA extends org.omg.PortableServer.Servant + implements GraphicsApp.RectangleOperations, org.omg.CORBA.portable.InvokeHandler +{ + + // Constructors + + private static java.util.Hashtable _methods = new java.util.Hashtable (); + static + { + _methods.put ("_get_objects", new java.lang.Integer (0)); + _methods.put ("_set_objects", new java.lang.Integer (1)); + _methods.put ("addObject", new java.lang.Integer (2)); + _methods.put ("removeObjectAtPosition", new java.lang.Integer (3)); + } + + public org.omg.CORBA.portable.OutputStream _invoke (String $method, + org.omg.CORBA.portable.InputStream in, + org.omg.CORBA.portable.ResponseHandler $rh) + { + org.omg.CORBA.portable.OutputStream out = null; + java.lang.Integer __method = (java.lang.Integer)_methods.get ($method); + if (__method == null) + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + + switch (__method.intValue ()) + { + + // hopping this will be an array of shapes. + case 0: // GraphicsApp/Rectangle/_get_objects + { + GraphicsApp.GraphicalObject $result[] = null; + $result = this.objects (); + out = $rh.createReply(); + GraphicsApp.ObjectSequenceHelper.write (out, $result); + break; + } + + + // hopping this will be an array of shapes. + case 1: // GraphicsApp/Rectangle/_set_objects + { + GraphicsApp.GraphicalObject newObjects[] = GraphicsApp.ObjectSequenceHelper.read (in); + this.objects (newObjects); + out = $rh.createReply(); + break; + } + + + // function to add shape + case 2: // GraphicsApp/Rectangle/addObject + { + GraphicsApp.GraphicalObject newShape = GraphicsApp.GraphicalObjectHelper.read (in); + this.addObject (newShape); + out = $rh.createReply(); + break; + } + + + // and may be remove a shape from a position? + case 3: // GraphicsApp/Rectangle/removeObjectAtPosition + { + try { + int index = in.read_ulong (); + this.removeObjectAtPosition (index); + out = $rh.createReply(); + } catch (GraphicsApp.RectanglePackage.IndexOutOfBounds $ex) { + out = $rh.createExceptionReply (); + GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.write (out, $ex); + } + break; + } + + default: + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + } + + return out; + } // _invoke + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:GraphicsApp/Rectangle:1.0"}; + + public String[] _all_interfaces (org.omg.PortableServer.POA poa, byte[] objectId) + { + return (String[])__ids.clone (); + } + + public Rectangle _this() + { + return RectangleHelper.narrow( + super._this_object()); + } + + public Rectangle _this(org.omg.CORBA.ORB orb) + { + return RectangleHelper.narrow( + super._this_object(orb)); + } + + +} // class RectanglePOA diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBounds.class b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBounds.class new file mode 100644 index 0000000..35d5dc4 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBounds.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBounds.java b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBounds.java new file mode 100644 index 0000000..3cf1082 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBounds.java @@ -0,0 +1,25 @@ +package GraphicsApp.RectanglePackage; + + +/** +* GraphicsApp/RectanglePackage/IndexOutOfBounds.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + +public final class IndexOutOfBounds extends org.omg.CORBA.UserException +{ + + public IndexOutOfBounds () + { + super(IndexOutOfBoundsHelper.id()); + } // ctor + + + public IndexOutOfBounds (String $reason) + { + super(IndexOutOfBoundsHelper.id() + " " + $reason); + } // ctor + +} // class IndexOutOfBounds diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBoundsHelper.class b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBoundsHelper.class new file mode 100644 index 0000000..c518ada Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBoundsHelper.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBoundsHelper.java b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBoundsHelper.java new file mode 100644 index 0000000..442bdca --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBoundsHelper.java @@ -0,0 +1,72 @@ +package GraphicsApp.RectanglePackage; + + +/** +* GraphicsApp/RectanglePackage/IndexOutOfBoundsHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + +abstract public class IndexOutOfBoundsHelper +{ + private static String _id = "IDL:GraphicsApp/Rectangle/IndexOutOfBounds:1.0"; + + public static void insert (org.omg.CORBA.Any a, GraphicsApp.RectanglePackage.IndexOutOfBounds that) + { + org.omg.CORBA.portable.OutputStream out = a.create_output_stream (); + a.type (type ()); + write (out, that); + a.read_value (out.create_input_stream (), type ()); + } + + public static GraphicsApp.RectanglePackage.IndexOutOfBounds extract (org.omg.CORBA.Any a) + { + return read (a.create_input_stream ()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + private static boolean __active = false; + synchronized public static org.omg.CORBA.TypeCode type () + { + if (__typeCode == null) + { + synchronized (org.omg.CORBA.TypeCode.class) + { + if (__typeCode == null) + { + if (__active) + { + return org.omg.CORBA.ORB.init().create_recursive_tc ( _id ); + } + __active = true; + org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember [0]; + org.omg.CORBA.TypeCode _tcOf_members0 = null; + __typeCode = org.omg.CORBA.ORB.init ().create_exception_tc (GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.id (), "IndexOutOfBounds", _members0); + __active = false; + } + } + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static GraphicsApp.RectanglePackage.IndexOutOfBounds read (org.omg.CORBA.portable.InputStream istream) + { + GraphicsApp.RectanglePackage.IndexOutOfBounds value = new GraphicsApp.RectanglePackage.IndexOutOfBounds (); + // read and discard the repository ID + istream.read_string (); + return value; + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, GraphicsApp.RectanglePackage.IndexOutOfBounds value) + { + // write the repository ID + ostream.write_string (id ()); + } + +} diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBoundsHolder.java b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBoundsHolder.java new file mode 100644 index 0000000..1143f43 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/RectanglePackage/IndexOutOfBoundsHolder.java @@ -0,0 +1,38 @@ +package GraphicsApp.RectanglePackage; + +/** +* GraphicsApp/RectanglePackage/IndexOutOfBoundsHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + +public final class IndexOutOfBoundsHolder implements org.omg.CORBA.portable.Streamable +{ + public GraphicsApp.RectanglePackage.IndexOutOfBounds value = null; + + public IndexOutOfBoundsHolder () + { + } + + public IndexOutOfBoundsHolder (GraphicsApp.RectanglePackage.IndexOutOfBounds initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.type (); + } + +} diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/Shape.class b/week1_TinsaeGhilay/Task2/GraphicsApp/Shape.class new file mode 100644 index 0000000..de12075 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/Shape.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/Shape.java b/week1_TinsaeGhilay/Task2/GraphicsApp/Shape.java new file mode 100644 index 0000000..c7c71f1 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/Shape.java @@ -0,0 +1,13 @@ +package GraphicsApp; + + +/** +* GraphicsApp/Shape.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + +public interface Shape extends ShapeOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity +{ +} // interface Shape diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHelper.class b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHelper.class new file mode 100644 index 0000000..bdce1ad Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHelper.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHelper.java b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHelper.java new file mode 100644 index 0000000..59328a6 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHelper.java @@ -0,0 +1,85 @@ +package GraphicsApp; + + +/** +* GraphicsApp/ShapeHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + +abstract public class ShapeHelper +{ + private static String _id = "IDL:GraphicsApp/Shape:1.0"; + + public static void insert (org.omg.CORBA.Any a, GraphicsApp.Shape that) + { + org.omg.CORBA.portable.OutputStream out = a.create_output_stream (); + a.type (type ()); + write (out, that); + a.read_value (out.create_input_stream (), type ()); + } + + public static GraphicsApp.Shape extract (org.omg.CORBA.Any a) + { + return read (a.create_input_stream ()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + synchronized public static org.omg.CORBA.TypeCode type () + { + if (__typeCode == null) + { + __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (GraphicsApp.ShapeHelper.id (), "Shape"); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static GraphicsApp.Shape read (org.omg.CORBA.portable.InputStream istream) + { + return narrow (istream.read_Object (_ShapeStub.class)); + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, GraphicsApp.Shape value) + { + ostream.write_Object ((org.omg.CORBA.Object) value); + } + + public static GraphicsApp.Shape narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof GraphicsApp.Shape) + return (GraphicsApp.Shape)obj; + else if (!obj._is_a (id ())) + throw new org.omg.CORBA.BAD_PARAM (); + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + GraphicsApp._ShapeStub stub = new GraphicsApp._ShapeStub (); + stub._set_delegate(delegate); + return stub; + } + } + + public static GraphicsApp.Shape unchecked_narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof GraphicsApp.Shape) + return (GraphicsApp.Shape)obj; + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + GraphicsApp._ShapeStub stub = new GraphicsApp._ShapeStub (); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHolder.class b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHolder.class new file mode 100644 index 0000000..c5428f6 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHolder.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHolder.java b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHolder.java new file mode 100644 index 0000000..71104c1 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeHolder.java @@ -0,0 +1,38 @@ +package GraphicsApp; + +/** +* GraphicsApp/ShapeHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + +public final class ShapeHolder implements org.omg.CORBA.portable.Streamable +{ + public GraphicsApp.Shape value = null; + + public ShapeHolder () + { + } + + public ShapeHolder (GraphicsApp.Shape initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = GraphicsApp.ShapeHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + GraphicsApp.ShapeHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return GraphicsApp.ShapeHelper.type (); + } + +} diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeOperations.class b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeOperations.class new file mode 100644 index 0000000..06a7622 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeOperations.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeOperations.java b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeOperations.java new file mode 100644 index 0000000..214172b --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapeOperations.java @@ -0,0 +1,19 @@ +package GraphicsApp; + + +/** +* GraphicsApp/ShapeOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + +public interface ShapeOperations +{ + + // draw to be overriden in java + void draw (); + + // and info + void showInfo (); +} // interface ShapeOperations diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ShapePOA.class b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapePOA.class new file mode 100644 index 0000000..600b4ee Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapePOA.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/ShapePOA.java b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapePOA.java new file mode 100644 index 0000000..fa39dc7 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/ShapePOA.java @@ -0,0 +1,82 @@ +package GraphicsApp; + + +/** +* GraphicsApp/ShapePOA.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + +public abstract class ShapePOA extends org.omg.PortableServer.Servant + implements GraphicsApp.ShapeOperations, org.omg.CORBA.portable.InvokeHandler +{ + + // Constructors + + private static java.util.Hashtable _methods = new java.util.Hashtable (); + static + { + _methods.put ("draw", new java.lang.Integer (0)); + _methods.put ("showInfo", new java.lang.Integer (1)); + } + + public org.omg.CORBA.portable.OutputStream _invoke (String $method, + org.omg.CORBA.portable.InputStream in, + org.omg.CORBA.portable.ResponseHandler $rh) + { + org.omg.CORBA.portable.OutputStream out = null; + java.lang.Integer __method = (java.lang.Integer)_methods.get ($method); + if (__method == null) + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + + switch (__method.intValue ()) + { + + // draw to be overriden in java + case 0: // GraphicsApp/Shape/draw + { + this.draw (); + out = $rh.createReply(); + break; + } + + + // and info + case 1: // GraphicsApp/Shape/showInfo + { + this.showInfo (); + out = $rh.createReply(); + break; + } + + default: + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + } + + return out; + } // _invoke + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:GraphicsApp/Shape:1.0"}; + + public String[] _all_interfaces (org.omg.PortableServer.POA poa, byte[] objectId) + { + return (String[])__ids.clone (); + } + + public Shape _this() + { + return ShapeHelper.narrow( + super._this_object()); + } + + public Shape _this(org.omg.CORBA.ORB orb) + { + return ShapeHelper.narrow( + super._this_object(orb)); + } + + +} // class ShapePOA diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/_GraphicalObjectStub.class b/week1_TinsaeGhilay/Task2/GraphicsApp/_GraphicalObjectStub.class new file mode 100644 index 0000000..65b20f5 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/_GraphicalObjectStub.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/_GraphicalObjectStub.java b/week1_TinsaeGhilay/Task2/GraphicsApp/_GraphicalObjectStub.java new file mode 100644 index 0000000..f9016b0 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/_GraphicalObjectStub.java @@ -0,0 +1,157 @@ +package GraphicsApp; + + +/** +* GraphicsApp/_GraphicalObjectStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// GraphicalShape object extends Shape +public class _GraphicalObjectStub extends org.omg.CORBA.portable.ObjectImpl implements GraphicsApp.GraphicalObject +{ + + + // unqualified member + public boolean is_filled () + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("_get_is_filled", true); + $in = _invoke ($out); + boolean $result = $in.read_boolean (); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return is_filled ( ); + } finally { + _releaseReply ($in); + } + } // is_filled + + + // unqualified member + public void is_filled (boolean newIs_filled) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("_set_is_filled", true); + $out.write_boolean (newIs_filled); + $in = _invoke ($out); + return; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + is_filled (newIs_filled ); + } finally { + _releaseReply ($in); + } + } // is_filled + + + // only time a shape can change is if it's in the matrix or if Dr.Strange is in town. + public String name () + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("_get_name", true); + $in = _invoke ($out); + String $result = $in.read_string (); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return name ( ); + } finally { + _releaseReply ($in); + } + } // name + + + // draw to be overriden in java + public void draw () + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("draw", true); + $in = _invoke ($out); + return; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + draw ( ); + } finally { + _releaseReply ($in); + } + } // draw + + + // and info + public void showInfo () + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("showInfo", true); + $in = _invoke ($out); + return; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + showInfo ( ); + } finally { + _releaseReply ($in); + } + } // showInfo + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:GraphicsApp/GraphicalObject:1.0", + "IDL:GraphicsApp/Shape:1.0"}; + + public String[] _ids () + { + return (String[])__ids.clone (); + } + + private void readObject (java.io.ObjectInputStream s) throws java.io.IOException + { + String str = s.readUTF (); + com.sun.corba.se.impl.orbutil.IORCheckImpl.check(str, "GraphicsApp._GraphicalObjectStub"); + String[] args = null; + java.util.Properties props = null; + org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props); + try { + org.omg.CORBA.Object obj = orb.string_to_object (str); + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate (); + _set_delegate (delegate); + } finally { + orb.destroy() ; + } + } + + private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException + { + String[] args = null; + java.util.Properties props = null; + org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props); + try { + String str = orb.object_to_string (this); + s.writeUTF (str); + } finally { + orb.destroy() ; + } + } +} // class _GraphicalObjectStub diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/_RectangleStub.class b/week1_TinsaeGhilay/Task2/GraphicsApp/_RectangleStub.class new file mode 100644 index 0000000..46307cb Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/_RectangleStub.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/_RectangleStub.java b/week1_TinsaeGhilay/Task2/GraphicsApp/_RectangleStub.java new file mode 100644 index 0000000..ba48e2f --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/_RectangleStub.java @@ -0,0 +1,140 @@ +package GraphicsApp; + + +/** +* GraphicsApp/_RectangleStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + + +// rectangle contains shapes which GraphicalObjects a +public class _RectangleStub extends org.omg.CORBA.portable.ObjectImpl implements GraphicsApp.Rectangle +{ + + + // hopping this will be an array of shapes. + public GraphicsApp.GraphicalObject[] objects () + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("_get_objects", true); + $in = _invoke ($out); + GraphicsApp.GraphicalObject $result[] = GraphicsApp.ObjectSequenceHelper.read ($in); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return objects ( ); + } finally { + _releaseReply ($in); + } + } // objects + + + // hopping this will be an array of shapes. + public void objects (GraphicsApp.GraphicalObject[] newObjects) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("_set_objects", true); + GraphicsApp.ObjectSequenceHelper.write ($out, newObjects); + $in = _invoke ($out); + return; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + objects (newObjects ); + } finally { + _releaseReply ($in); + } + } // objects + + + // function to add shape + public void addObject (GraphicsApp.GraphicalObject newShape) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("addObject", true); + GraphicsApp.GraphicalObjectHelper.write ($out, newShape); + $in = _invoke ($out); + return; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + addObject (newShape ); + } finally { + _releaseReply ($in); + } + } // addObject + + + // and may be remove a shape from a position? + public void removeObjectAtPosition (int index) throws GraphicsApp.RectanglePackage.IndexOutOfBounds + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("removeObjectAtPosition", true); + $out.write_ulong (index); + $in = _invoke ($out); + return; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + if (_id.equals ("IDL:GraphicsApp/Rectangle/IndexOutOfBounds:1.0")) + throw GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.read ($in); + else + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + removeObjectAtPosition (index ); + } finally { + _releaseReply ($in); + } + } // removeObjectAtPosition + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:GraphicsApp/Rectangle:1.0"}; + + public String[] _ids () + { + return (String[])__ids.clone (); + } + + private void readObject (java.io.ObjectInputStream s) throws java.io.IOException + { + String str = s.readUTF (); + com.sun.corba.se.impl.orbutil.IORCheckImpl.check(str, "GraphicsApp._RectangleStub"); + String[] args = null; + java.util.Properties props = null; + org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props); + try { + org.omg.CORBA.Object obj = orb.string_to_object (str); + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate (); + _set_delegate (delegate); + } finally { + orb.destroy() ; + } + } + + private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException + { + String[] args = null; + java.util.Properties props = null; + org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props); + try { + String str = orb.object_to_string (this); + s.writeUTF (str); + } finally { + orb.destroy() ; + } + } +} // class _RectangleStub diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/_ShapeStub.class b/week1_TinsaeGhilay/Task2/GraphicsApp/_ShapeStub.class new file mode 100644 index 0000000..dbc2981 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsApp/_ShapeStub.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsApp/_ShapeStub.java b/week1_TinsaeGhilay/Task2/GraphicsApp/_ShapeStub.java new file mode 100644 index 0000000..6e88e12 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsApp/_ShapeStub.java @@ -0,0 +1,91 @@ +package GraphicsApp; + + +/** +* GraphicsApp/_ShapeStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from Graphics.idl +* Tuesday, November 11, 2025 6:46:29 PM CET +*/ + +public class _ShapeStub extends org.omg.CORBA.portable.ObjectImpl implements GraphicsApp.Shape +{ + + + // draw to be overriden in java + public void draw () + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("draw", true); + $in = _invoke ($out); + return; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + draw ( ); + } finally { + _releaseReply ($in); + } + } // draw + + + // and info + public void showInfo () + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("showInfo", true); + $in = _invoke ($out); + return; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + showInfo ( ); + } finally { + _releaseReply ($in); + } + } // showInfo + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:GraphicsApp/Shape:1.0"}; + + public String[] _ids () + { + return (String[])__ids.clone (); + } + + private void readObject (java.io.ObjectInputStream s) throws java.io.IOException + { + String str = s.readUTF (); + com.sun.corba.se.impl.orbutil.IORCheckImpl.check(str, "GraphicsApp._ShapeStub"); + String[] args = null; + java.util.Properties props = null; + org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props); + try { + org.omg.CORBA.Object obj = orb.string_to_object (str); + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate (); + _set_delegate (delegate); + } finally { + orb.destroy() ; + } + } + + private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException + { + String[] args = null; + java.util.Properties props = null; + org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props); + try { + String str = orb.object_to_string (this); + s.writeUTF (str); + } finally { + orb.destroy() ; + } + } +} // class _ShapeStub diff --git a/week1_TinsaeGhilay/Task2/GraphicsClient.class b/week1_TinsaeGhilay/Task2/GraphicsClient.class new file mode 100644 index 0000000..3f608f5 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsClient.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsClient.java b/week1_TinsaeGhilay/Task2/GraphicsClient.java new file mode 100644 index 0000000..016f7b8 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsClient.java @@ -0,0 +1,98 @@ +// Copyright and License + +import GraphicsApp.*; +import org.omg.CosNaming.*; +import org.omg.CORBA.*; +import org.omg.PortableServer.*; +import org.omg.PortableServer.POA; + +// because we need GraphicalObject we have to do an implementation of it here. +// reversing the HelloServer.java here +class Graph extends GraphicalObjectPOA { + private boolean filled; + private String name; + private ORB orb; + + public Graph(String name, boolean filled) { + this.name = name; + this.filled = filled; + } + + public void setORB(ORB orb_val) { + this.orb = orb_val; + } + + // draw + public void draw() { + System.out.println("Drawing graph: " + name); + } + + // show info + public void showInfo() { + System.out.println("Graph Info -> Name: " + name + ", Filled: " + filled); + } + + // getter for is filled + public boolean is_filled() { + return filled; + } + + // setter for is filled + public void is_filled(boolean value) { + this.filled = value; + } + + + // name getter, not setting it. + public String name() { + return name; + } +} + +public class GraphicsClient +{ + static Rectangle rect; + + public static void main(String args[]) + { + try{ + // create and initialize the ORB + ORB orb = ORB.init(args, null); + + // get reference to rootpoa and activate the POAManager + POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); + rootpoa.the_POAManager().activate(); + + // reversing steps from HelloServer here as well. + // create servant and register it with the ORB + Graph graph = new Graph("Circle", true); + graph.setORB(orb); + + // get object reference from the servant + org.omg.CORBA.Object ref = rootpoa.servant_to_reference(graph); + GraphicalObject object = GraphicalObjectHelper.narrow(ref); + + + // get the root naming context + org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); + + // Use NamingContextExt instead of NamingContext. This is + // part of the Interoperable naming Service. + NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); + + // resolve the Object Reference in Naming + String name = "Graphics"; + rect = RectangleHelper.narrow(ncRef.resolve_str(name)); + + + System.out.println("Obtained a handle on server object: " + rect); + rect.addObject(object); + rect.removeObjectAtPosition(0); + + } catch (Exception e) { + System.out.println("ERROR : " + e) ; + e.printStackTrace(System.out); + } + } + +} diff --git a/week1_TinsaeGhilay/Task2/GraphicsServer.class b/week1_TinsaeGhilay/Task2/GraphicsServer.class new file mode 100644 index 0000000..79b7b21 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/GraphicsServer.class differ diff --git a/week1_TinsaeGhilay/Task2/GraphicsServer.java b/week1_TinsaeGhilay/Task2/GraphicsServer.java new file mode 100644 index 0000000..da7da24 --- /dev/null +++ b/week1_TinsaeGhilay/Task2/GraphicsServer.java @@ -0,0 +1,105 @@ +// GraphicsServer.java + +// I am not testing this server for fear of errors +// because if there are errors, I wont stop trying to debugg it untill tomorrow. +import GraphicsApp.*; +import org.omg.CosNaming.*; +import org.omg.CORBA.*; +import org.omg.PortableServer.*; +import org.omg.PortableServer.POA; +import java.util.*; + + +// overriding the rectangle Class. +// copying from the Hello Project, I believe we extend the RectanglePOA class +class Rect extends RectanglePOA { + private ORB orb; + private GraphicalObject[] objects; + + public Rect() { + this.objects = new GraphicalObject[0]; + } + + public void setORB(ORB orb_val) { + this.orb = orb_val; + } + + // getter + public GraphicalObject[] objects() { + return this.objects; + } + + // setter + public void objects(GraphicalObject[] newObject) { + this.objects = newObject; + } + + // add objects + public void addObject(GraphicalObject newObject) { + List temp = new ArrayList<>(Arrays.asList(this.objects)); + temp.add(newObject); + this.objects = temp.toArray(new GraphicalObject[0]); + } + + + // remove an object + public void removeObjectAtPosition(int index) + throws GraphicsApp.RectanglePackage.IndexOutOfBounds { + + if (index < 0 || index >= this.objects.length) { + throw new GraphicsApp.RectanglePackage.IndexOutOfBounds(); + } + + List temp = new ArrayList<>(Arrays.asList(this.objects)); + temp.remove(index); + this.objects = temp.toArray(new GraphicalObject[0]); + } +} + + +public class GraphicsServer { + + public static void main(String args[]) { + try{ + // create and initialize the ORB + ORB orb = ORB.init(args, null); + + // get reference to rootpoa and activate the POAManager + POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); + rootpoa.the_POAManager().activate(); + + // create servant and register it with the ORB + Rect rect = new Rect(); + rect.setORB(orb); + + // get object reference from the servant + org.omg.CORBA.Object ref = rootpoa.servant_to_reference(rect); + Rectangle href = RectangleHelper.narrow(ref); + + // get the root naming context + org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); + + // Use NamingContextExt which is part of the Interoperable + // Naming Service (INS) specification. + NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); + + // bind the Object Reference in Naming + String name = "Graphics"; + NameComponent path[] = ncRef.to_name( name ); + ncRef.rebind(path, href); + + System.out.println("GraphicsServer ready and waiting ..."); + + // wait for invocations from clients + orb.run(); + } + + catch (Exception e) { + System.err.println("ERROR: " + e); + e.printStackTrace(System.out); + } + + System.out.println("GraphicsServer Exiting ..."); + + } +} diff --git a/week1_TinsaeGhilay/Task2/Rect.class b/week1_TinsaeGhilay/Task2/Rect.class new file mode 100644 index 0000000..8cca025 Binary files /dev/null and b/week1_TinsaeGhilay/Task2/Rect.class differ diff --git a/week1_TinsaeGhilay/app/.gitignore b/week1_TinsaeGhilay/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/week1_TinsaeGhilay/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/build.gradle b/week1_TinsaeGhilay/app/build.gradle new file mode 100644 index 0000000..924061d --- /dev/null +++ b/week1_TinsaeGhilay/app/build.gradle @@ -0,0 +1,37 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdk 31 + + defaultConfig { + applicationId "com.tgk.test" + minSdk 21 + targetSdk 31 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'com.google.android.material:material:1.4.0' + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/libs/.gitkeep b/week1_TinsaeGhilay/app/libs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/week1_TinsaeGhilay/app/proguard-rules.pro b/week1_TinsaeGhilay/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/week1_TinsaeGhilay/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/src/androidTest/java/com/tgk/test/ExampleInstrumentedTest.java b/week1_TinsaeGhilay/app/src/androidTest/java/com/tgk/test/ExampleInstrumentedTest.java new file mode 100644 index 0000000..470d75a --- /dev/null +++ b/week1_TinsaeGhilay/app/src/androidTest/java/com/tgk/test/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.tgk.test; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.tgk.test", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/src/main/AndroidManifest.xml b/week1_TinsaeGhilay/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..fb69ac2 --- /dev/null +++ b/week1_TinsaeGhilay/app/src/main/AndroidManifest.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/src/main/java/com/tgk/test/.gitkeep b/week1_TinsaeGhilay/app/src/main/java/com/tgk/test/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/week1_TinsaeGhilay/app/src/main/java/com/tgk/test/MainActivity.kt b/week1_TinsaeGhilay/app/src/main/java/com/tgk/test/MainActivity.kt new file mode 100644 index 0000000..e69de29 diff --git a/week1_TinsaeGhilay/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/week1_TinsaeGhilay/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/week1_TinsaeGhilay/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/src/main/res/drawable/ic_launcher_background.xml b/week1_TinsaeGhilay/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/week1_TinsaeGhilay/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/week1_TinsaeGhilay/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/week1_TinsaeGhilay/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/week1_TinsaeGhilay/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/week1_TinsaeGhilay/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/week1_TinsaeGhilay/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..801563d Binary files /dev/null and b/week1_TinsaeGhilay/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/week1_TinsaeGhilay/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..14ecbb5 Binary files /dev/null and b/week1_TinsaeGhilay/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/week1_TinsaeGhilay/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..19b4549 Binary files /dev/null and b/week1_TinsaeGhilay/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/week1_TinsaeGhilay/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..2155e20 Binary files /dev/null and b/week1_TinsaeGhilay/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/week1_TinsaeGhilay/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..a6b14be Binary files /dev/null and b/week1_TinsaeGhilay/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/week1_TinsaeGhilay/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..ebe3ce0 Binary files /dev/null and b/week1_TinsaeGhilay/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/week1_TinsaeGhilay/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..3ed8cc3 Binary files /dev/null and b/week1_TinsaeGhilay/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/week1_TinsaeGhilay/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1f8b5d0 Binary files /dev/null and b/week1_TinsaeGhilay/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/week1_TinsaeGhilay/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..960ac6a Binary files /dev/null and b/week1_TinsaeGhilay/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/week1_TinsaeGhilay/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/week1_TinsaeGhilay/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..01649d7 Binary files /dev/null and b/week1_TinsaeGhilay/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/week1_TinsaeGhilay/app/src/main/res/values-night/themes.xml b/week1_TinsaeGhilay/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..dd8a87e --- /dev/null +++ b/week1_TinsaeGhilay/app/src/main/res/values-night/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/src/main/res/values/colors.xml b/week1_TinsaeGhilay/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/week1_TinsaeGhilay/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/src/main/res/values/strings.xml b/week1_TinsaeGhilay/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..ce714ae --- /dev/null +++ b/week1_TinsaeGhilay/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Test + \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/src/main/res/values/themes.xml b/week1_TinsaeGhilay/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..e6a340f --- /dev/null +++ b/week1_TinsaeGhilay/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/week1_TinsaeGhilay/app/src/test/java/com/tgk/test/ExampleUnitTest.java b/week1_TinsaeGhilay/app/src/test/java/com/tgk/test/ExampleUnitTest.java new file mode 100644 index 0000000..c63113b --- /dev/null +++ b/week1_TinsaeGhilay/app/src/test/java/com/tgk/test/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.tgk.test; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/week1_TinsaeGhilay/build.gradle b/week1_TinsaeGhilay/build.gradle new file mode 100644 index 0000000..2106b82 --- /dev/null +++ b/week1_TinsaeGhilay/build.gradle @@ -0,0 +1,17 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + google() + mavenCentral() + } + dependencies { + classpath "com.android.tools.build:gradle:7.0.2" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/week1_TinsaeGhilay/gradle.properties b/week1_TinsaeGhilay/gradle.properties new file mode 100644 index 0000000..52f5917 --- /dev/null +++ b/week1_TinsaeGhilay/gradle.properties @@ -0,0 +1,19 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app"s APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true \ No newline at end of file diff --git a/week1_TinsaeGhilay/gradle/wrapper/gradle-wrapper.jar b/week1_TinsaeGhilay/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/week1_TinsaeGhilay/gradle/wrapper/gradle-wrapper.jar differ diff --git a/week1_TinsaeGhilay/gradle/wrapper/gradle-wrapper.properties b/week1_TinsaeGhilay/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..488723f --- /dev/null +++ b/week1_TinsaeGhilay/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Oct 18 19:16:13 CEST 2021 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/week1_TinsaeGhilay/gradlew.bat b/week1_TinsaeGhilay/gradlew.bat new file mode 100644 index 0000000..ac1b06f --- /dev/null +++ b/week1_TinsaeGhilay/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/week1_TinsaeGhilay/myGrade.txt b/week1_TinsaeGhilay/myGrade.txt new file mode 100644 index 0000000..6e0f160 --- /dev/null +++ b/week1_TinsaeGhilay/myGrade.txt @@ -0,0 +1,4 @@ +Exercise 1: done 100% +Exercise 2: done 100% +--------------------- +Total: 100% diff --git a/week1_TinsaeGhilay/settings.gradle b/week1_TinsaeGhilay/settings.gradle new file mode 100644 index 0000000..81b63de --- /dev/null +++ b/week1_TinsaeGhilay/settings.gradle @@ -0,0 +1,10 @@ +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + jcenter() // Warning: this repository is going to shut down soon + } +} +rootProject.name = "Test" +include ':app' diff --git a/week1_TinsaeGhilay/solutions.txt b/week1_TinsaeGhilay/solutions.txt new file mode 100644 index 0000000..6e0f160 --- /dev/null +++ b/week1_TinsaeGhilay/solutions.txt @@ -0,0 +1,4 @@ +Exercise 1: done 100% +Exercise 2: done 100% +--------------------- +Total: 100% diff --git a/week2_TinsaeGhilay.zip b/week2_TinsaeGhilay.zip new file mode 100644 index 0000000..fc3984a Binary files /dev/null and b/week2_TinsaeGhilay.zip differ diff --git a/week2_TinsaeGhilay/Task5/.gitignore b/week2_TinsaeGhilay/Task5/.gitignore new file mode 100644 index 0000000..480bdf5 --- /dev/null +++ b/week2_TinsaeGhilay/Task5/.gitignore @@ -0,0 +1,39 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ +.kotlin + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/week2_TinsaeGhilay/Task5/.idea/.gitignore b/week2_TinsaeGhilay/Task5/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/week2_TinsaeGhilay/Task5/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/week2_TinsaeGhilay/Task5/.idea/encodings.xml b/week2_TinsaeGhilay/Task5/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/week2_TinsaeGhilay/Task5/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/week2_TinsaeGhilay/Task5/.idea/misc.xml b/week2_TinsaeGhilay/Task5/.idea/misc.xml new file mode 100644 index 0000000..0c04b52 --- /dev/null +++ b/week2_TinsaeGhilay/Task5/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/week2_TinsaeGhilay/Task5/.idea/vcs.xml b/week2_TinsaeGhilay/Task5/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/week2_TinsaeGhilay/Task5/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/week2_TinsaeGhilay/Task5/pom.xml b/week2_TinsaeGhilay/Task5/pom.xml new file mode 100644 index 0000000..c1f12da --- /dev/null +++ b/week2_TinsaeGhilay/Task5/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + org.distributed + Task5 + 1.0-SNAPSHOT + + + 25 + 25 + UTF-8 + + + + org.apache.kafka + kafka-clients + 3.9.1 + + + + \ No newline at end of file diff --git a/week2_TinsaeGhilay/Task5/src/main/java/org/distributed/Consumer.java b/week2_TinsaeGhilay/Task5/src/main/java/org/distributed/Consumer.java new file mode 100644 index 0000000..2861318 --- /dev/null +++ b/week2_TinsaeGhilay/Task5/src/main/java/org/distributed/Consumer.java @@ -0,0 +1,48 @@ +package org.distributed; + +import org.apache.kafka.clients.consumer.*; + +import java.time.Duration; +import java.util.Collections; +import java.util.Properties; + +public class Consumer { + public static void main(String[] args) { + + // Kafka configuration properties + Properties props = new Properties(); + props.put(Tag.SERVER.label, Tag.SERVER_URL.label); + props.put(Tag.DESERIALISER_KEY.label, Tag.DESERIALISER.label); + props.put(Tag.DESERIALISER_VAL.label, Tag.DESERIALISER.label); + props.put(Tag.GID.label, Tag.GROUP.label); + + // Creating KafkaConsumer instance + KafkaConsumer consumer = new KafkaConsumer<>(props); + + // subscribe to topic + + consumer.subscribe(Collections.singletonList(Tag.TOPIC.label)); + // Starting consuming the messages + while (true) { + + try (consumer) { // it gave me no other way to close consumer + + // Providing poll for new records from Kafka topic + ConsumerRecords records = consumer.poll(Duration.ofMillis(100)); + + // Processing the received records + for (ConsumerRecord record : records) { + // Printing the received message + System.out.println("Nerds Received a message: " + record.value()); + + } + + } catch (Exception e) { + System.err.println("Consumer: " + e.getMessage()); + } + + } + + } + +} diff --git a/week2_TinsaeGhilay/Task5/src/main/java/org/distributed/Producer.java b/week2_TinsaeGhilay/Task5/src/main/java/org/distributed/Producer.java new file mode 100644 index 0000000..718c1bd --- /dev/null +++ b/week2_TinsaeGhilay/Task5/src/main/java/org/distributed/Producer.java @@ -0,0 +1,28 @@ +package org.distributed; + +import java.util.Properties; +import org.apache.kafka.clients.producer.*; + +public class Producer { + public static void main(String[] args) { + + // Kafka configuration properties + Properties props = new Properties(); + props.put(Tag.SERVER.label, Tag.SERVER_URL.label); + props.put(Tag.SERIALISER_KEY.label, Tag.SERIALISER.label); + props.put(Tag.SERIALISER_VAL.label, Tag.SERIALISER.label); + + // Creating KafkaProducer instance + KafkaProducer producer = new KafkaProducer<>(props); + + // Topic and message that we want to send + String message = "Hello, Nerds Welcome to Kafka!"; + + // Sending our message to Kafka topic + producer.send(new ProducerRecord<>(Tag.TOPIC.label, message)); + + // Closing the producer + producer.close(); + } + +} diff --git a/week2_TinsaeGhilay/Task5/src/main/java/org/distributed/Tag.java b/week2_TinsaeGhilay/Task5/src/main/java/org/distributed/Tag.java new file mode 100644 index 0000000..78f3347 --- /dev/null +++ b/week2_TinsaeGhilay/Task5/src/main/java/org/distributed/Tag.java @@ -0,0 +1,27 @@ +package org.distributed; + +public enum Tag { + // Server + SERVER("bootstrap.servers"), + SERVER_URL("localhost:9092"), + // deserialiser + DESERIALISER_KEY("key.deserializer"), + DESERIALISER_VAL("value.deserializer"), + DESERIALISER("org.apache.kafka.common.serialization.StringDeserializer"), + // serialiser + SERIALISER_KEY("key.serializer"), + SERIALISER_VAL("value.serializer"), + SERIALISER("org.apache.kafka.common.serialization.StringSerializer"), + // ids + GID("group.id"), + GROUP("consumer_GROUP"), + // Topic + TOPIC("nerds"); + + public final String label; + + private Tag(String label) { + this.label = label; + } + +} diff --git a/week2_TinsaeGhilay/solutions.txt b/week2_TinsaeGhilay/solutions.txt new file mode 100644 index 0000000..8a14a0b --- /dev/null +++ b/week2_TinsaeGhilay/solutions.txt @@ -0,0 +1,5 @@ +Exercise 1: not mandatory +Exercise 2: done 100% +Exercise 3: done 100% +Exercise 4: done 100% +Exercise 5: not mandatory, done 100%