This commit is contained in:
Alexander Munch-Hansen 2019-10-17 11:04:30 +02:00
commit 646d4a297d
2 changed files with 32 additions and 39 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea/

70
lol.rb
View File

@ -4,8 +4,6 @@ require_relative 'Type'
require_relative 'functional_functions' require_relative 'functional_functions'
require_relative 'Filter' require_relative 'Filter'
# Hi! Steffan was here... # Hi! Steffan was here...
container_obj = "ferries" container_obj = "ferries"
@ -17,8 +15,6 @@ sorting_one = Type.new("String", "Name")
sorting_two = Type.new("int", "Length") sorting_two = Type.new("int", "Length")
sorting_three = Type.new("int", "Width") sorting_three = Type.new("int", "Width")
sorting_two.comparator = ">"
sorting_three.comparator = ">"
def construct_class(name_of_class, parameters, to_string_template, sorting_filters) def construct_class(name_of_class, parameters, to_string_template, sorting_filters)
@ -26,7 +22,7 @@ def construct_class(name_of_class, parameters, to_string_template, sorting_filte
fields = "" fields = ""
parameters.each do |x| parameters.each do |x|
fields += "private #{x[:type]} #{x[:name]};" fields += "private #{x[:type]} #{x[:name]}; \n"
end end
tmptmp = parameters.map { |x| "#{x[:type]} #{x[:name]}"} tmptmp = parameters.map { |x| "#{x[:type]} #{x[:name]}"}
@ -96,50 +92,46 @@ def construct_driver(class_name, parameters, methods, container_class, container
methods_to_print = "" methods_to_print = ""
maggie = methods.map do |x| maggie = methods.map do |x|
if x[:print] if x[:print]
" "System.out.println(lol.#{x[:name]}(#{args x[:parameters]}));"
System.out.println(lol.#{x[:name]}(#{args x[:parameters]}));
"
else else
"lol.#{x[:name]}(#{args x[:parameters]});" "lol.#{x[:name]}(#{args x[:parameters]});"
end end
end end
driver_string = " driver_string = "
public class TestDriver { public class TestDriver {
public TestDriver(){} public TestDriver(){}
public static void test() { public static void test() {
var tmp1 = new #{class_name}(#{args parameters}); var tmp1 = new #{class_name}(#{args parameters});
var tmp2 = new #{class_name}(#{args parameters}); var tmp2 = new #{class_name}(#{args parameters});
var tmp3 = new #{class_name}(#{args parameters}); var tmp3 = new #{class_name}(#{args parameters});
var tmp4 = new #{class_name}(#{args parameters}); var tmp4 = new #{class_name}(#{args parameters});
var tmp5 = new #{class_name}(#{args parameters}); var tmp5 = new #{class_name}(#{args parameters});
System.out.println(tmp1); System.out.println(tmp1);
System.out.println(tmp2); System.out.println(tmp2);
System.out.println(tmp3); System.out.println(tmp3);
System.out.println(tmp4); System.out.println(tmp4);
System.out.println(tmp5); System.out.println(tmp5);
#{container_class} lol = new #{container_class}(#{args container_params}); #{container_class} lol = new #{container_class}(#{args container_params});
lol.add#{class_name}(tmp1); lol.add#{class_name}(tmp1);
lol.add#{class_name}(tmp2); lol.add#{class_name}(tmp2);
lol.add#{class_name}(tmp3); lol.add#{class_name}(tmp3);
lol.add#{class_name}(tmp4); lol.add#{class_name}(tmp4);
lol.add#{class_name}(tmp5); lol.add#{class_name}(tmp5);
System.out.println(\"\"); System.out.println(\"\");
System.out.println(\"Some checkpoint\"); System.out.println(\"Some checkpoint\");
#{maggie.join "\n\n System.out.println(\"Some Checkpoint\"); \n\n"} #{maggie.join "\n\n\tSystem.out.println(\"Some Checkpoint\"); \n\t"}
}
} public static void main(String[] args) {
TestDriver.test();
public static void main(String[] args) { }
TestDriver.test(); }
}
}
" "
end end
@ -147,11 +139,11 @@ def construct_container(name, parameters, given_fields, methods, arraylist_name)
fields = "" fields = ""
parameters.each do |x| parameters.each do |x|
fields += "private #{x[:type]} #{x[:name]};" fields += "private #{x[:type]} #{x[:name]};\n"
end end
given_fields.each do |x| given_fields.each do |x|
fields += " private #{x[:type]} #{x[:name]};" fields += " private #{x[:type]} #{x[:name]};\n"
end end
maggie = methods.map do |x| maggie = methods.map do |x|