Commit e22b9a02 authored by Thomas Dupriez's avatar Thomas Dupriez

New Branch featuring a proposal for the architecture of the project and an...

New Branch featuring a proposal for the architecture of the project and an example of Scala-Java interoperability
parent 24439d3b
SBT:
- To install sbt: http://www.scala-sbt.org/0.13/tutorial/Setup.html
- To use sbt, place yourself at the root of the project (where there is the build.sbt file) and enter "sbt" in the command line. It will start sbt. Then enter "compile" to compile the whole project, or "run" to compile the whole project and execute it.
- To use sbt, place yourself at the root of the project (where there is the build.sbt file) and enter "sbt" in the command line. It will start sbt. Then enter "compile" to compile the files that changed since the last compiling, or "run" to do the same job than "compile" + run the project.
ARCHITECTURE:
- The Main classes for the different groups are in the scala folder (I tried to use java, but SBT didn't detect java main classes properly). But that doesn't prevent you from coding in the java folder and then only putting a single function call in the scala main class, to use your java code.
TO USE LIBRARIES:
Library dependencies can be added in two ways:
- unmanaged dependencies are jars dropped into the lib directory
- managed dependencies are configured in the build definition (build.sbt) and downloaded automatically from repositories
SCALA/JAVA INTEROPERABILITY:
- An interesting document on the subject: http://www.codecommit.com/blog/java/interop-between-java-and-scala
- An example can be found in the Graphics code (which shows how the code from both the java and scala folder from the graphics group can cooperate). Just run the project using the GraphicsMain Class
......@@ -9,5 +9,9 @@ resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/release
//sbt will check that library and keep it around so we can use it (it's a library for building concurrent message-driven applications on the jvm
libraryDependencies += "com.typesafe.akka" % "akka-actor" % "2.0.2"
// append -deprecation to the options passed to the Scala compiler
scalacOptions += "-deprecation"
// append several options to the list of options passed to the Java compiler
javacOptions ++= Seq("-source", "1.8", "-target", "1.8")
import core.*;
import graphics.*;
//<Just a try>
import scalaHello_package.*;
//</Just a try>
class Main {
public static void main (String[] args){
System.out.println("Hello World");
Core c = new Core();
//<Just a try>
ScalaHello.sayHelloToJava();
//</Just a try>
}
}
// import core.*;
// import graphics.*;
// public class Main {
// public static void main (String[] args){
// System.out.println("Hello World, I'm a Main class from Java");
// Core c = new Core();
// }
// }
import core.*;
import graphics.*;
//<Just a try>
import scalaHello_package.*;
//</Just a try>
class Main {
public static void main (String[] args){
System.out.println("Hello World");
Core c = new Core();
//<Just a try>
ScalaHello.sayHelloToJava()
//</Just a try>
}
}
package graphics;
public class Graphics {
// public static void main (String[] args){
// System.out.println("Hello World");
// }
}
package graphics;
public class JavaGraphics {
public String whatToSay = "Hi, I'm an object of the JavaGraphics class, from src/main/java/graphics/JavaGraphics.java";
public void sayHi (){
System.out.println(whatToSay);
}
}
package map_generation;
\ No newline at end of file
package network;
\ No newline at end of file
package user_interface;
\ No newline at end of file
package scalaHello_package
object ScalaHello {
def sayHelloToJava() = {
println("Hello JAVA, my name is SCALA!")
}
}
\ No newline at end of file
package core
object CoreMain {
def main(args: Array[String]): Unit = {
println("Hi, I'm the object CoreMain, from /scala/core/CoreMain.scala")
}
}
\ No newline at end of file
import core._
import graphics._
object GlobalMain {
def main(args: Array[String]): Unit = {
println("Hi, I'm the GlobalMain object from /scala/core/GlobalMain.scala")
}
}
\ No newline at end of file
// package graphics;
// public class GraphicsTestClass {
// // public static void main (String[] args){
// // System.out.println("Hello World");
// // }
// public void sayHi (){
// System.out.println("Hello, this is Graphics, from Graphics.java");
// }
// }
\ No newline at end of file
package graphics
class ScalaGraphics extends JavaGraphics{
whatToSay = "Hi, I'm an object of the ScalaGraphics class, which extends the JavaGraphics class. I'm from src/main/scala/graphics/Graphics.scala"
}
\ No newline at end of file
package graphics
object GraphicsMain {
def main(args: Array[String]): Unit = {
println("Hi, I'm the object GraphicsMain, from /scala/graphics/Graphics.scala")
val jG = new JavaGraphics
jG.sayHi()
val sG = new ScalaGraphics
sG.sayHi()
}
}
\ No newline at end of file
package map_generation
object MapGenerationMain {
def main(args: Array[String]): Unit = {
println("Hi, I'm the object MapGenerationMain, from /scala/map_generation/MapGenerationMain.scala")
}
}
\ No newline at end of file
package network
object NetworkMain {
def main(args: Array[String]): Unit = {
println("Hi, I'm the object NetworkMain, from /scala/network/NetworkMain.scala")
}
}
\ No newline at end of file
package user_interface
object UserInterfacekMain {
def main(args: Array[String]): Unit = {
println("Hi, I'm the object UserInterfaceMain, from /scala/user_interface/UserInterfaceMain.scala")
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment