cs349 преди 6 години
родител
ревизия
0859131e1e
променени са 15 файла, в които са добавени 150 реда и са изтрити 5 реда
  1. 0 1
      A0/.gitignore
  2. 0 1
      A1/.gitignore
  3. 0 1
      A2/.gitignore
  4. 0 1
      A3/.gitignore
  5. 0 1
      A4/.gitignore
  6. 19 0
      Vagrantfile
  7. 1 0
      assignments/a0/a0.md
  8. 1 0
      assignments/a1/a1.md
  9. 1 0
      assignments/a2/a2.md
  10. 1 0
      assignments/a3/a3.md
  11. 1 0
      assignments/a4/a4.md
  12. 33 0
      examples/java/Hello.java
  13. 15 0
      examples/java/makefile
  14. 59 0
      examples/x/hello.cpp
  15. 19 0
      examples/x/makefile

+ 0 - 1
A0/.gitignore

@@ -1 +0,0 @@
-*.class

+ 0 - 1
A1/.gitignore

@@ -1 +0,0 @@
-*.class

+ 0 - 1
A2/.gitignore

@@ -1 +0,0 @@
-*.class

+ 0 - 1
A3/.gitignore

@@ -1 +0,0 @@
-*.class

+ 0 - 1
A4/.gitignore

@@ -1 +0,0 @@
-*.class

+ 19 - 0
Vagrantfile

@@ -0,0 +1,19 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+Vagrant.configure("2") do |config|
+  config.vm.box = "ubuntu/xenial64"
+  config.vm.provider "virtualbox" do |vb|
+    vb.name = "CS349"
+    vb.gui = true
+    vb.memory = "2048"
+  end
+
+  config.vm.synced_folder "assignments/", "/home/ubuntu/cs349/assignments"
+  config.vm.synced_folder "examples/", "/home/ubuntu/cs349/examples"
+  config.vm.provision "shell", inline: <<-SHELL
+    apt-get -y update
+    apt-get -y install lubuntu-desktop openjdk-8-jdk g++ libx11-dev zip git
+    passwd -d -u ubuntu
+    reboot
+  SHELL
+end

+ 1 - 0
assignments/a0/a0.md

@@ -0,0 +1 @@
+# A0

+ 1 - 0
assignments/a1/a1.md

@@ -0,0 +1 @@
+# A1

+ 1 - 0
assignments/a2/a2.md

@@ -0,0 +1 @@
+# A2

+ 1 - 0
assignments/a3/a3.md

@@ -0,0 +1 @@
+# A3

+ 1 - 0
assignments/a4/a4.md

@@ -0,0 +1 @@
+# A4

+ 33 - 0
examples/java/Hello.java

@@ -0,0 +1,33 @@
+import javax.swing.*;
+import java.io.PrintWriter;
+import java.awt.Font;
+
+public class Hello extends JFrame {
+
+	public static void main(String args[]) {
+		new Hello();
+
+		try {
+			PrintWriter writer = new PrintWriter("results.txt", "UTF-8");
+			writer.println("Java: " + System.getProperty("java.runtime.name"));
+			writer.println("Java Version: " + System.getProperty("java.version"));
+			writer.println("OS Name: " + System.getProperty("os.name"));
+			writer.println("OS Version: " + System.getProperty("os.version"));
+			writer.println("OS Architecture: " + System.getProperty("os.arch"));
+			writer.println("Total Memory (MB): " + Runtime.getRuntime().totalMemory() / (1024*1024));
+			writer.println("Max Memory (MB): " + Runtime.getRuntime().maxMemory() / (1024*1024)); 
+			writer.close();			
+		} catch (Exception ex) {
+			System.out.println(ex.toString());
+		}
+	}
+	
+	Hello() {
+		JLabel l = new JLabel("Hello Java");
+		l.setFont(new Font("Serif", Font.PLAIN, 24));
+		add(l);
+		setSize(200, 100);
+		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+		setVisible(true);
+	}
+}

+ 15 - 0
examples/java/makefile

@@ -0,0 +1,15 @@
+# super simple makefile
+# call it using 'make NAME=name_of_code_file_without_extension'
+# (assumes a .java extension)
+NAME = "Hello"
+
+all:
+	@echo "Compiling..."
+	javac *.java
+
+run: all
+	@echo "Running..."
+	java $(NAME)
+
+clean:
+	rm -rf *.class

+ 59 - 0
examples/x/hello.cpp

@@ -0,0 +1,59 @@
+/*
+CS 349 Hello X Windows
+
+- - - - - - - - - - - - - - - - - - - - - -
+
+Commands to compile and run:
+
+    g++ -o drawing.min drawing.min.cpp -L/usr/X11R6/lib -lX11 -lstdc++
+    ./drawing.min
+
+Note: the -L option and -lstdc++ may not be needed on some machines.
+
+*/
+
+#include <unistd.h>
+#include <cstdlib>
+#include <iostream>
+#include <X11/Xlib.h>
+
+Display* display;
+Window window;
+
+int main( int argc, char* argv[] ) {
+
+  // open display
+  display = XOpenDisplay("");
+  if (!display) exit (-1);
+  int screen = DefaultScreen(display);
+  int w = 200;
+  int h = 100;
+  window = XCreateSimpleWindow(display, DefaultRootWindow(display),
+                               10, 10, w, h, 2,
+                               BlackPixel(display, screen), WhitePixel(display, screen));
+  XMapRaised(display, window);
+  XFlush(display);
+
+  // give server 10ms to get set up before sending drawing commands
+  usleep(10 * 1000);           
+
+  // drawing demo with graphics context here ...
+  GC gc = XCreateGC(display, window, 0, 0);       // create a graphics context
+  XSetForeground(display, gc, BlackPixel(display, screen));
+  XSetBackground(display, gc, WhitePixel(display, screen));
+
+  // load a larger font
+  XFontStruct * font;
+  font = XLoadQueryFont (display, "12x24");
+  XSetFont (display, gc, font->fid);
+
+  // draw text
+  std::string text("hello X Windows");
+  XDrawImageString( display, window, gc,
+                    10, h / 2, text.c_str(), text.length());
+
+  XFlush(display);
+  std::cout << "ENTER2exit"; std::cin.get(); // wait for input
+  XCloseDisplay(display);
+
+}

+ 19 - 0
examples/x/makefile

@@ -0,0 +1,19 @@
+# super simple makefile
+# call it using 'make NAME=name_of_code_file_without_extension'
+# (assumes a .cpp extension)
+NAME = "hello"
+
+# Add $(MAC_OPT) to the compile line for macOS 
+# (should be ignored by Linux, set to nothing if causing problems)
+MAC_OPT = -I/opt/X11/include
+
+all:
+	@echo "Compiling..."
+	g++ -o $(NAME) $(NAME).cpp -L/opt/X11/lib -lX11 -lstdc++ $(MAC_OPT)
+
+run: all
+	@echo "Running..."
+	./$(NAME) 
+
+clean:
+	-rm *o