From d3e22bafd1130a1efa4588f06c44c40e2cd60f63 Mon Sep 17 00:00:00 2001 From: Magdalena Kalin Date: Wed, 16 Oct 2019 22:18:59 +0200 Subject: [PATCH 1/2] Add newline to fields --- lol.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lol.rb b/lol.rb index bc2e2e4..77e3e87 100644 --- a/lol.rb +++ b/lol.rb @@ -4,12 +4,11 @@ require_relative 'Type' require_relative 'functional_functions' require_relative 'Filter' - - # Hi! Steffan was here... container_obj = "ferries" + def construct_class(name_of_class, parameters, to_string_template) sorting_one = Type.new("String", "Name") sorting_two = Type.new("int", "Length") @@ -21,7 +20,7 @@ def construct_class(name_of_class, parameters, to_string_template) fields = "" parameters.each do |x| - fields += "private #{x[:type]} #{x[:name]};" + fields += "private #{x[:type]} #{x[:name]}; \n" end tmptmp = parameters.map { |x| "#{x[:type]} #{x[:name]}"} @@ -142,11 +141,11 @@ def construct_container(name, parameters, given_fields, methods, arraylist_name) fields = "" parameters.each do |x| - fields += "private #{x[:type]} #{x[:name]};" + fields += "private #{x[:type]} #{x[:name]};\n" end given_fields.each do |x| - fields += " private #{x[:type]} #{x[:name]};" + fields += " private #{x[:type]} #{x[:name]};\n" end maggie = methods.map do |x| From 3bafc92f47f5e63845c3abaf5bc6a5b749d4a42d Mon Sep 17 00:00:00 2001 From: Magdalena Kalin Date: Thu, 17 Oct 2019 09:56:33 +0200 Subject: [PATCH 2/2] Beautify TestDriver --- .gitignore | 1 + lol.rb | 60 +++++++++++++++++++++++++----------------------------- 2 files changed, 29 insertions(+), 32 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/lol.rb b/lol.rb index 77e3e87..416bf3b 100644 --- a/lol.rb +++ b/lol.rb @@ -90,50 +90,46 @@ def construct_driver(class_name, parameters, methods, container_class, container methods_to_print = "" maggie = methods.map do |x| if x[:print] - " - System.out.println(lol.#{x[:name]}(#{args x[:parameters]})); - " + "System.out.println(lol.#{x[:name]}(#{args x[:parameters]}));" else "lol.#{x[:name]}(#{args x[:parameters]});" end end driver_string = " - public class TestDriver { +public class TestDriver { - public TestDriver(){} + public TestDriver(){} - public static void test() { - var tmp1 = new #{class_name}(#{args parameters}); - var tmp2 = new #{class_name}(#{args parameters}); - var tmp3 = new #{class_name}(#{args parameters}); - var tmp4 = new #{class_name}(#{args parameters}); - var tmp5 = new #{class_name}(#{args parameters}); + public static void test() { + var tmp1 = new #{class_name}(#{args parameters}); + var tmp2 = new #{class_name}(#{args parameters}); + var tmp3 = new #{class_name}(#{args parameters}); + var tmp4 = new #{class_name}(#{args parameters}); + var tmp5 = new #{class_name}(#{args parameters}); - System.out.println(tmp1); - System.out.println(tmp2); - System.out.println(tmp3); - System.out.println(tmp4); - System.out.println(tmp5); + System.out.println(tmp1); + System.out.println(tmp2); + System.out.println(tmp3); + System.out.println(tmp4); + 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}(tmp2); - lol.add#{class_name}(tmp3); - lol.add#{class_name}(tmp4); - lol.add#{class_name}(tmp5); - System.out.println(\"\"); - System.out.println(\"Some checkpoint\"); - #{maggie.join "\n\n System.out.println(\"Some Checkpoint\"); \n\n"} + lol.add#{class_name}(tmp1); + lol.add#{class_name}(tmp2); + lol.add#{class_name}(tmp3); + lol.add#{class_name}(tmp4); + lol.add#{class_name}(tmp5); + System.out.println(\"\"); + System.out.println(\"Some checkpoint\"); + #{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