This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dsa.tries; | |
public class Trie{ | |
private Node root; | |
public Trie(){ | |
root = new Node(' '); | |
} | |
public void insert(String s){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dsa.tries; | |
import java.util.Collection; | |
import java.util.LinkedList; | |
/** | |
* @author Braga | |
*/ | |
public class Node { | |
char content; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo add-apt-repository ppa:webupd8team/java | |
sudo apt-get update | |
sudo apt-get install oracle-java8-installer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hudson.util.IOException2: Slave JVM has not reported exit code. Is it still running? | |
at hudson.plugins.sshslaves.SSHLauncher.startSlave(SSHLauncher.java:953) | |
at hudson.plugins.sshslaves.SSHLauncher.access$400(SSHLauncher.java:133) | |
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:711) | |
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:696) | |
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) | |
at java.util.concurrent.FutureTask.run(FutureTask.java:166) | |
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) | |
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) | |
at java.lang.Thread.run(Thread.java:724) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models/instrument.rb | |
class Instrument | |
attr_accessor :units | |
def initialize(status, units) | |
@status = status | |
@units = units | |
end | |
def turn_on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models/hotel.rb | |
class Hotel | |
attr_accessor :floors | |
def initialize(num_floors, num_of_mc, num_of_sc, controller) | |
@floors = [] | |
num_floors.times{ @floors << Floor.new(num_of_mc, num_of_sc) } | |
controller.add_observer(self) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#models/corridor.rb | |
class Corridor | |
attr_accessor :lights | |
attr_accessor :air_conditioners | |
def initialize | |
@lights = [Instrument.new(STATUS_OFF, DEFAULT_UNITS_LIGHTS)] | |
@air_conditioners = [Instrument.new(STATUS_OFF, DEFAULT_UNITS_AC)] | |
@movement = false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#models/controller.rb | |
require 'observer' | |
class Controller | |
include Observable | |
attr_accessor :hotel | |
def initialize(num_floors, num_of_mc, num_of_sc) | |
@hotel = Hotel.new(num_floors, num_of_mc, num_of_sc, self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#init/constants.rb | |
STATUS_OFF = 'OFF' | |
STATUS_ON = 'ON' | |
DEFAULT_UNITS_LIGHTS = 5 | |
DEFAULT_UNITS_AC = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pry' | |
Dir["./init/*.rb"].each {|file| require file } | |
Dir["./models/*.rb"].each {|file| require file } | |
print "Enter the number of Floors: " | |
floors = gets.chomp | |
print "Enter the number of Main Corridors: " | |
mc_per_floor = gets.chomp | |
print "Enter the number of Sub Corridors: " | |
sc_per_floor = gets.chomp |