Row’s Quantum Soaker


In the dimly lit basement of an old Victorian house, Dr. Rowan “Row” Hawthorne tinkered with wires, circuits, and vials of iridescent liquid. His unruly hair stood on end, a testament to his relentless pursuit of scientific breakthroughs. Row was no ordinary scientist; he was a maverick, a dreamer, and a little bit mad.

His obsession? Teleportation. The ability to traverse space instantaneously fascinated him. He’d read every paper, dissected every failed experiment, and even tried meditating in a sensory deprivation tank to unlock the secrets of the universe. But progress remained elusive.

One stormy night, as rain drummed against the windowpanes, Row had a revelation. He stared at the super soaker lying on his cluttered workbench. Its neon green plastic seemed out of place among the high-tech equipment. Yet, it held promise—a vessel for his audacious experiment.

Row connected the soaker to his quantum teleporter, a contraption that looked like a cross between a particle accelerator and a steampunk time machine. He filled the soaker’s reservoir with the iridescent liquid—a concoction of exotic particles and moonlight. The moment of truth had arrived.

He aimed the soaker at a potted fern in the corner of the room. The fern quivered, its fronds trembling with anticipation. Row squeezed the trigger, and a beam of shimmering energy shot out, enveloping the plant. The fern vanished, leaving behind a faint echo of chlorophyll.

Row’s heart raced. He stepped onto the teleporter’s platform, gripping the soaker like a futuristic weapon. The room blurred, and he felt weightless. In an instant, he materialized in the heart of the United Nations General Assembly—an audacious move, even for a scientist.

Diplomats gasped as Row stood before them, dripping wet and clutching the super soaker. The UN Secretary-General, a stern-faced woman named Elena Vargas, raised an eyebrow. “Who are you, and why are you interrupting—”

Row cut her off. “Ladies and gentlemen, I bring you the solution to global conflict.” He waved the soaker dramatically. “This humble water gun is now a weapon of peace.”

The assembly erupted in laughter. Row ignored them. “This device teleports emotions,” he declared. “Love, empathy, forgiveness—they’re all encoded in these water molecules. Imagine if we could share these feelings across borders, erase hatred, and build bridges.”

Elena Vargas leaned forward. “You’re insane.”

“Am I?” Row adjusted his lab coat. “Watch this.” He sprayed a mist of teleportation-infused water into the air. The room shimmered, and suddenly, delegates from warring nations embraced. Tears flowed, and old grievances dissolved. The super soaker had become a conduit for understanding.

Word spread. Row’s Quantum Soaker became a symbol of hope. He traveled to conflict zones, dousing soldiers and rebels alike. The Middle East, Kashmir, the Korean Peninsula—all witnessed miraculous transformations. The soaker’s payload wasn’t water; it was humanity’s shared longing for peace.

As the Nobel Committee awarded Row the Peace Prize, he stood on the podium, soaking wet, and addressed the world. “We’ve spent centuries fighting over land, resources, and ideologies,” he said. “But what if we fought for compassion, kindness, and understanding instead?”

And so, the super soaker became a relic of a new era. Rows of them lined the halls of diplomacy, ready to douse flames of hatred. The world learned that sometimes, the most powerful inventions emerge from the unlikeliest of sources—a mad scientist’s basement, a child’s toy, and a dream of a better tomorrow.

And Dr. Rowan Hawthorne? He continued his experiments, pushing the boundaries of science. But he never forgot the day he wielded a super soaker and changed the course of history—one teleportation at a time.

How to Implement a Stack in Java

If you are a computer science major when you take Data Structures and Algorithms you are going to have to learn about a Stack.  Java has a built in Stack class that you can use so you would probably never have to implement your own. In this example we will start with the Stack interface to formally define how our stack will be implemented.

Stack.java


/**
*
* @author Copypasteearth
*interface for the Stack implementation
* @param <T>
* generic parameter T
*/
public interface Stack<T>
{
/*
* push element onto the top of the stack
* @element
* the item to be pushed onto the top of the stack
*
*/
public void push(T element);
/**
* removes the top element from the stack and returns it
* @throws
* throws stackunderflowexception if the stack is empty
* @return
* returns T element
*/
public T pop();
/**
* lets you see the current top element of the stack without removing it
* @throws
* throws stackunderflowexception if the stack is empty
* @return
* returns T element (the top of the stack)
*/
public T top();
/**
* checks to see if the stack is empty
* @return
* returns true if the stack is empty, false otherwise
*/
public boolean isEmpty();
/**
* gets the size of the stack
* @return
* returns an integer representing how many items are on the stack
*/
public int getSize();

}

Next we will need a class that holds our information so we define the Node class to hold the data and a reference to the next Node in the stack.

Node.java


/**
*
* @author Copypasteearth
* Node class used to dynamically keep track of
* elements on the stack
*/
public class Node<T> {

/** holds the reference to Object of the node*/
public T data;
/** holds the reference to next node of the stack*/
public Node<T> next;
/**
*
* @param element
* element to be placed in data variable of Node
* @param next
* Node to be placed in next variable of Node
*/
public Node(T element,Node<T> next) {

this.data = element;
this.next = next;

}

}

Now we will define an Exception just incase someone trys to access the top of the stack and it is empty.

StackUnderflowException.java


/**
*
* @author Copypasteearth
* StackUnderflowException to be thrown when the
* stack tries to perform a getter method on an empty stack
*/
public class StackUnderflowException extends RuntimeException {

public StackUnderflowException() {
super();
// TODO Auto-generated constructor stub
}

public StackUnderflowException(String arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}

public StackUnderflowException(Throwable arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}

public StackUnderflowException(String arg0, Throwable arg1) {
super(arg0, arg1);
// TODO Auto-generated constructor stub
}

public StackUnderflowException(String arg0, Throwable arg1, boolean arg2,
boolean arg3) {
super(arg0, arg1, arg2, arg3);
// TODO Auto-generated constructor stub
}

}

And finally here is the implementation of the Stack interface, in a class called UnboundedStackImplementation.

UnboundedStackImplementation.java


/**
* @author Copypasteearth
*
* UnboundedStackImplementation is the version of a Stack
* created with the Stack interface dynamically creating
* instances of Node class to keep references to elements
* in the stack
*/
public class UnboundedStackImplementation<T> implements Stack<T> {

/** the count of how many elements are in the stack */
private int count;
/** the reference to the element on the top of the stack */
private Node<T> top;

/**
* constructor sets values of top and count and returns an
* instance of UnboundedStackImplementation
*/
public UnboundedStackImplementation()
{
this.count = 0;
this.top = null;
}

/*
* push element onto the top of the stack
* @element
* the item to be pushed onto the top of the stack
*
*/
@Override
public void push(T element) {

//create new node with element as data and top as next
Node<T> currentNode = new Node<T>(element,top);
//set top to the new node
top = currentNode;
//increment count
count++;


}

/**
* removes the top element from the stack and returns it
* @throws
* throws stackunderflowexception if the stack is empty
* @return
* returns T element
*/
@Override
public T pop() {
//get T with top method, may throw StackUnderflowException
T result = top();
//set top data to null
top.data = null;
//set top to the top next node
top = top.next;
//decrement count
count--;
return result;

}

/**
* lets you see the current top element of the stack without removing it
* @throws
* throws stackunderflowexception if the stack is empty
* @return
* returns T element (the top of the stack)
*/
@Override
public T top() {

//prepare result T to be returned by top
T result = null;
// if stack is not empty
if(!isEmpty()){
//set result to top variable data
result = top.data;
}else{
// if stack is empty there is no data to be returned
throw new StackUnderflowException("StackUnderflowException -- The Stack is empty!!!");
}

return result;
}

/**
* checks to see if the stack is empty
* @return
* returns true if the stack is empty, false otherwise
*/
@Override
public boolean isEmpty() {
if(top == null)
return true;
else
return false;
}

/**
* gets the size of the stack
* @return
* returns an integer representing how many items are on the stack
*/
@Override
public int getSize() {

return count;
}

}

And that’s it, I hope you appreciate this little demonstration about the data structure that is very commonly used in practice.  There are a ton of different data structures to choose from and some are better in certain situations than others.

%d bloggers like this: