id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
e9183ce3-9e56-4920-bc41-e4a34f4d9337 | private static Vector<Object[]> makeCustomerVector(int numCustomers) {
String firstName;
String lastName;
String nationality;
char gender;
Date dateOfBirth;
Date expiryDate;
String idNumber;
Vector<Object[]> customerObjectVector = new Vector<Object[]>();
... |
8bc64bb8-f75f-4ce5-b687-5c038bff468a | private static String randomName() {
String randomName = "";
for (int i = 0; i < 6; i++) {
char addChar = ALPHABET[(int) (Math.random()*26)];
if (i == 0) {
addChar = Character.toUpperCase(addChar);
}
randomName += addChar+"";
}
... |
eb801dcc-db1a-4caf-bf88-d6fe96b4f8a3 | private static String randomNationality() {
String randomNationality = "";
for (int i = 0; i < 3; i++) {
char addChar = ALPHABET[(int) (Math.random()*26)];
Character.toUpperCase(addChar);
randomNationality += addChar;
}
return randomNationality;
} |
fad1a701-5ad8-43d4-8e8a-58b7487824ad | private static char randomGender() {
char randomGender = 'X';
randomGender = (((int) (Math.random()*2)) == 0) ? 'M' : 'F';
return randomGender;
} |
5321853f-c059-447c-a867-ef699f6d5d2a | private static Date randomDate(Date startDate) { // date 1-4 years from start
Date randomDate = new Date(
startDate.getTime()+(((long) Math.random())*94672800L+31557600L));
return randomDate;
} |
dfaecd39-5a16-4d47-9b89-dc96f063c570 | private static String randomId() {
int randomId = 0;
for (int i = 0; i < 9; i++) {
int currentPower = ((int) Math.pow((double) 10, (double) i));
randomId += (currentPower * ((int) (Math.random()*10)));
}
return randomId+"";
} |
41e4902f-5677-436b-b335-983b2ad3ab79 | private static long randomSleep() {
long randomSleep = (long) ((Math.random()*1000)+1000);
return randomSleep;
} |
2eb8a2fb-e6c5-43c8-acc5-c3a8045806df | public DriversLicense(String firstName, String lastName, String nationality,
char gender, Date dateOfBirth, Date expiryDate) {
super(firstName,lastName,nationality,gender,dateOfBirth,expiryDate);
} |
29abc651-19e8-4495-8a76-2a064571d3ca | Receptionist(String strategy,
SynchronizedQueue<Customer> customerQueue,
SynchronizedQueue<Customer> licensingQueue,
SynchronizedQueue<Customer> eyeTestingQueue,
SynchronizedQueue<Customer> translatingQueue,
SynchronizedQueue<UAEDriversLicense> successQueue,
... |
dddc3b19-f927-4635-894f-0bbb7b4bd131 | private boolean hasDocuments(Customer customer) {
if ((customer.driversLicense != null &&
customer.emiratesId != null &&
customer.passport != null) ||
(((int) (Math.random()*5)) > 3)) { // possible to pass even without documents
return true;
} ... |
59a46a85-904e-4920-9c0e-f3ed75176d78 | private void placeCustomer(Customer customer) { // doesn't care about eye tests or translations
if (!hasDocuments(customer)) {
failureQueue.add(customer);
System.out.println("FAILURE AT RECEPTIONIST FOR: " + customer);
System.out.println("("+successQueue.size()+" successes, "... |
f23c9631-3bfd-4c03-b65c-1c7d06e3b13f | private SynchronizedQueue<Customer> randomQueue() {
double random = Math.random();
if (random < 0.33) {
return eyeTestingQueue;
} else if (random < 0.66) {
return translatingQueue;
} else {
return licensingQueue;
}
} |
a04aaeff-29d6-4a38-aace-306be664f2e4 | private SynchronizedQueue<Customer> peekQueue() {
if (eyeTestingQueue.peekTime() <= translatingQueue.peekTime() &&
eyeTestingQueue.peekTime() <= licensingQueue.peekTime()) {
return eyeTestingQueue;
} else if (translatingQueue.peekTime() <= eyeTestingQueue.peekTime() &&
... |
e9ecce48-4f7f-4140-8833-9de6328bed56 | private SynchronizedQueue<Customer> fewestQueue() {
if (eyeTestingQueue.size() <= translatingQueue.size() &&
eyeTestingQueue.size() <= licensingQueue.size()) {
return eyeTestingQueue;
} else if (translatingQueue.size() <= eyeTestingQueue.size() &&
translatingQ... |
ebbeef3d-19d5-4aa4-b6fd-19324cbb676d | public void run() {
while ((failureQueue.size() + successQueue.size()) != numCustomers) {
Customer customer = customerQueue.poll();
if (customer != null) {
System.out.println("\tCustomer processed by receptionist: " + customer);
try {
... |
d5e8c536-bed2-41ad-8714-908c461e88eb | public Snapshot(Node[] n, int pId, Widget w, int nsnaps) throws IOException
{
nodes = n;
processId = pId;
bw = new BufferedWriter(new FileWriter("process_" + processId + "_log.txt"));
widget = w;
isStateRecorded = new boolean[nsnaps];
markersFromOthers = new HashMap<Integer,Set<Integer>>();
incomingChann... |
9f979079-58a1-4cbe-9373-be65a2d93879 | public void receiveMarker(int id, int snapId, TimeStamp t) throws IOException
{
if (!isStateRecorded[snapId]) {
initiateSnapshot(snapId,t);
}
markersFromOthers.get(snapId).add(id);
// Snapshot ends
if (markersFromOthers.get(snapId).size() == nodes.length - 1) {
for (Entry<Integer, Queue<String>> ... |
3b72ea66-eadc-400a-a01c-e8e6ab5a68f2 | public void initiateSnapshot(Integer snapshotId, TimeStamp t) throws IOException
{
Set<Integer>markersFromOthersForThisSnapshot = new HashSet<Integer>();
markersFromOthers.put(snapshotId,markersFromOthersForThisSnapshot);
isStateRecorded[snapshotId] = true;
Map<Integer, Queue<String>>incomingChannelByProcessF... |
d8a81bdb-cf44-4f77-8070-1cb7d19b2adf | private boolean sendMessage(String hostName, Integer portNumber,int i, int snapshotId){
try {
Socket socket = new Socket(hostName, portNumber);
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
out.println(processId + ":marker-" +snapshotId);
out.flush();
... |
026f588a-8fd6-4a89-95f3-4803b867c9db | public void checkAndAddMessage(String s, Integer snapshotId)
{
int fromProcess = Integer.parseInt(s.split(":")[0]);
if (isStateRecorded[snapshotId] && !markersFromOthers.get(snapshotId).contains(fromProcess)) {
if(!incomingChannelByProcess.get(snapshotId).containsKey(fromProcess)) {
incomingChannelByProc... |
6e955397-6639-454c-b7af-09b027e58d98 | Listener(Node[] x, int y, TimeStamp t, Widget w, Snapshot s, Integer snapId) {
nodes = x;
id = y;
timestamp = t;
widget = w;
snapshot = s;
snapshotId = snapId;
} |
c5a26175-aa48-42cf-8643-4b9945daedbc | public int parseLamport(String msg)
{
return Integer.parseInt(msg.split(":")[2]);
} |
58aeff43-95cf-4502-b95c-fe47c7c52b52 | public int[] parseVector(String msg)
{
String ls = msg.split(":")[3];
String[] lsArr = ls.split(",");
int[] v = new int[lsArr.length];
for (int i=0; i<lsArr.length; i++) {
v[i] = Integer.parseInt(lsArr[i]);
}
return v;
} |
6c62f9fc-0285-42e6-95a9-781d329bea91 | public void run() {
try {
ServerSocket serverSocket = new ServerSocket(nodes[id].portNumber);
//Socket clientSocket = serverSocket.accept();
InputStream input = null;
while (true) {
//.sleep(1000);
//Thread.sleep(1000);
Socket connection = serverSocket.accept();
input = co... |
68eb1f08-1816-47a6-8b7f-94fa18d365ea | public void putToSleep() throws Exception{
Thread.sleep(1000);
} |
77bed50c-a904-44a8-ba42-445b99b2846f | public void acquireLock(){
while(!myLock.tryLock());
return;
} |
b6eb9aa7-9d2b-496d-b796-dd3fe8332026 | public void releaseLock(){
myLock.unlock();
} |
5fb2109e-062a-4fb6-8d4c-9e2bd9963a07 | public TimeStamp(int size, int nodeIndex)
{
lamport = 0;
vector = new int[size];
this.nodeIndex = nodeIndex;
} |
4322244b-8cbf-47cc-b35e-f3a5aaec24e6 | public String getVector()
{
String s = "";
for (int a : vector) {
s += a + ",";
}
return s.substring(0, s.length() - 1);
} |
c4ef158a-3934-483b-8cba-307a616068db | public int getLamport()
{
return lamport;
} |
61e0ba5a-743d-45d0-bce9-b0503fad792a | public void increment(int l, int[] v)
{
if (l == -1) {
lamport += 1;
} else {
lamport = Math.max(l, lamport) + 1;
}
if (v == null) {
vector[nodeIndex]++;
return;
} else {
for (int i=0; i<v.length; i++) {
if (i != nodeIndex) {
vector[i] = Math.max(v[i], vector[i]);
} else {
... |
49c509a7-8938-4ee8-8c18-5e305c72a779 | private static void readFile(){
try {
// FileReader reads text files in the default encoding.
FileReader fileReader = new FileReader(INPUT_FILE);
// Always wrap FileReader in BufferedReader.
BufferedReader bufferedReader = new BufferedReader(fileReader);
... |
e198840b-80b8-40cd-9442-0a7f6a6691bb | public void initiateSnapshot()
{
} |
6b0ed7c6-9c5e-4210-8ee6-d49fedcf09ce | public static void main(String[] args) throws NumberFormatException, IOException, InterruptedException, Exception
{
String input;
processId = Integer.parseInt(args[0]);
snapshotId = 0;
BufferedReader br = new BufferedReader(new FileReader("input_file_" + processId + ".txt"));
Widget widget = new Widget(In... |
cecfc16f-d876-459c-a532-d31eed52d4d1 | private static boolean sendMessage(String hostName, Integer portNumber, String message, Widget widget, int []temp)
{
try {
Socket socket = new Socket(hostName, portNumber);
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
out.println(message);
out.flush();
... |
ddd669b5-793a-410b-a94b-20f45abfd2c0 | public void putToSleep() throws Exception{
Thread.sleep(1000);
} |
84ceb897-0640-44de-ac0b-410c306377eb | public Widget(int c, int q)
{
cost = c;
quantity = q;
} |
4396082b-c743-43c7-93cf-68250b483085 | public int[] getState()
{
while(!myLock.tryLock());
int[] result = {cost, quantity};
return result;
} |
bca91b77-e45f-40dc-a7c6-aeb8334276e5 | public void update(int c, int q)
{
cost += c;
quantity += q;
myLock.unlock();
} |
fd499675-dfdf-4773-a4f2-ae6ef4c3b287 | public void releaseLock()
{
myLock.unlock();
} |
2eb7903a-904e-46e6-8745-543a72d6deda | public void run() throws NumberFormatException, IOException
{
BufferedReader br = new BufferedReader(new FileReader("input.txt"));
int processId = Integer.parseInt(br.readLine());
BufferedWriter bw = new BufferedWriter(new FileWriter("input_file_0.txt"));
int count = 0;
while (count < numberSnapshots) {
... |
256ee5f0-b865-40d5-9122-8451a4273f9e | public static void main(String[] args) throws NumberFormatException, IOException
{
GenerateInputFile main = new GenerateInputFile();
numberSnapshots = Integer.parseInt(args[0]);
main.run();
} |
7260fe36-b711-447a-910e-580c1164540a | public static void main(String[] args) throws IOException {
System.out.println("Server Running");
//int[] times = { 810, 815, 910, 915, 1010, 1025, 1035, 1125, 1135, 1225, 1300, 1305, 1400, 1405, 1500 };
int[] times = { 952, 953, 1010 };
String s = "";
for(int i = 0; i < times.length; i++){
s+=times... |
138356e5-cb2b-491b-ac25-25a8a88ec24a | public void playSound(String filename) {
String strFilename = filename;
try {
soundFile = new File(strFilename);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
try {
audioStream = AudioSystem.getAudioInputStream(soundFile);
} catch (Exception e) {
e.printStackTrace();
Sy... |
f18f35ed-efb1-4697-adfe-4060ec9a3f92 | RemindTask() {
super();
} |
70f2b978-c500-4780-ba57-3f952c07c06b | RemindTask(Timer t) {
super();
timer = t;
} |
d8887ce8-b9ed-4614-803a-24f010269155 | public void run() {
System.out.println("Time's up!%n");
System.out.println("fired off an event!");
Reminded = true;
PlaySound s = new PlaySound();
s.playSound("BackinBlack.wav");
try {
timer.cancel(); // Terminate the timer thread
} catch (Exception e) {
}
} |
81a5f42b-e5b8-4d88-b010-b3705a307f49 | public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
DigitalClock myClock = new DigitalClock();
f.add(myClock);
f.pack();
f.setVisible(true);
} |
d4c9b9a2-4a71-431e-9d10-56676ac20ad1 | public void setStringTime(String xyz) {
this.stringTime = xyz;
} |
282c3691-2a52-4291-8729-180188a0d2f7 | public int findMinimumBetweenTwoNumbers(int a, int b) {
return (a <= b) ? a : b;
} |
d8f4f8ae-9ac7-47c9-a78e-31c669934a22 | DigitalClock() {
Timer t1 = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
repaint();
}
});
t1.start();
} |
4105c964-8b2f-4c58-8cb3-708a693cbb25 | public void actionPerformed(ActionEvent e) {
repaint();
} |
d0aa9193-2a72-4949-bca8-c67f8df449c0 | public void paintComponent(Graphics g) {
super.paintComponent(g);
Calendar now = Calendar.getInstance();
hour = now.get(Calendar.HOUR_OF_DAY);
minute = now.get(Calendar.MINUTE);
second = now.get(Calendar.SECOND);
if (hour < 10) {
this.correctionHour = "0";
}
if (hour >= 10) {
this.corr... |
ef5bf2c4-72ae-4e23-8e6e-7e7323ea137e | public Dimension getPreferredSize() {
return new Dimension(200, 150);
} |
b53aabe0-ff3a-43ee-a898-813f47dad0ff | public static void main(String[] args) throws IOException {
String serverAddress = JOptionPane
.showInputDialog("Enter IP Address of a machine that is\n"
+ "running the date service on port 9090:");
Socket s = new Socket(serverAddress, 9090);
BufferedReader input = new BufferedReader(new InputStreamRead... |
b6a719aa-4068-4302-a010-5e75943ff1b8 | public BellInterface() {
on = new JButton("On");
off = new JButton("Off");
this.add(on);
this.add(off);
} |
59d39b3d-26da-4f84-8d4a-481a1f7f47ba | public Reminder(int seconds) {
timer = new Timer();
} |
53f4a558-7800-4902-aa00-423f4232e93f | public static void main(String args[]) throws IOException {
SimpleDigitalClock digitalClock = new SimpleDigitalClock();
BellInterface bellInterface = new BellInterface();
// Get the Date corresponding to 11:01:00 pm today.
String answer = "";
String serverAddress = JOptionPane
.showInputDialog("Enter I... |
e23c27f3-701d-49f0-aea5-8a8057a4c3e2 | public Saphire() {
this.form = Form.UNDEFINED;
this.size = 0;
} |
a83957af-08d4-400d-aa07-6b6fdb1e5546 | public Saphire(Form form) {
this.form = form;
this.size = 0;
} |
bac8a175-6d86-44bf-a0df-bea6453c1b05 | public Saphire(Form form, int size) {
this.form = form;
this.size = size;
} |
7cae736a-f949-48d5-8801-41e9f55946d2 | public void setForm(Form form) {
this.form = form;
} |
9541ed94-a58c-4191-b461-0b59318472b1 | public Form getForm() {
return this.form;
} |
4896cc27-5bb8-41e5-bdff-0164edb4ef25 | public void setSize(int size) {
this.size = size;
} |
0f4b6ed4-80a3-4c80-8fb7-befd3ed6eecd | public int getSize() {
return this.size;
} |
486e691f-4d7c-4d69-ab70-7690d3e87ca0 | @Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(getClass().getName());
builder.append("\nWeight: ").append(this.getWeight());
builder.append("\nColor: ").append(this.getColor().toString());
builder.append("\nHardness: ").append... |
db93bdee-3b62-40e9-bb22-e1fde1711a90 | public int getId(){
return id;
} |
65b4e24b-4d35-42a5-8ffb-63db2d0dcaa8 | public void setId(int id){
this.id=id;
} |
d55e9c98-510a-4c8c-9f4b-80434688c065 | public String getName(){
return name;
} |
2d0bf227-90c9-480a-a65c-05f7956bce88 | public void setName(String name){
this.name=name;
} |
baffe7a9-6773-44fe-a142-04689b1aafca | public String getOrigin(){
return origin;
} |
a67e6f40-8da7-4a73-ad4e-d1012ba50681 | public void setOrigin(String origin){
this.origin=origin;
} |
ad0e741e-04c5-4479-85b5-8cebd1862132 | public String getPreciousness(){
return preciousness;
} |
fcd03bcf-8824-41f0-965c-0701e8e3e78f | public void setPreciousness(String preciousness){
this.preciousness=preciousness;
} |
6a78ff8f-04a7-4527-a580-4e75b56a9812 | public int getFaces(){
return faces;
} |
dd06f691-44e5-46ed-a570-99599231ac4b | public void setFaces(int faces){
this.faces=faces;
} |
997ec2e4-37e9-4bfe-9983-52944822f2d7 | public void setWeight(int weight) {
this.weight = weight;
} |
65f4639b-8762-4003-a81d-d87fef6c40b2 | public int getWeight() {
return weight;
} |
62f769e9-74ec-472b-8dd1-5d3dbfa22f77 | public void setColor(String color) {
this.color = color;
} |
2d497d26-9a76-4f28-bfc9-01cc5e21a496 | public String getColor() {
return color;
} |
7a5a05a4-fdbb-433a-b647-da4f2833b3ba | public void setHardness(int hardness) {
this.hardness = hardness;
} |
5f519453-129b-4fa9-8815-65d4c09f8d11 | public int getHardness() {
return hardness;
} |
5f1ac4fe-f8cc-429d-8c59-2a1f729f489c | public void setTransparency(double transparency) {
this.transparency = transparency;
} |
82c21bf4-28ae-4b7e-b9b3-502b3b41605b | public double getTransparency() {
return transparency;
} |
7f705731-c12c-4101-ad98-df4339c5b965 | public int getValue(){
return value;
} |
aa1339af-a6b1-4569-9786-58e5fa63c893 | public void setValue(int value){
this.value=value;
} |
d89c00c3-3abf-4ccb-8d3c-f9506cc2f268 | @Override
public String toString() {
return "Stone{" +
"id=" + id +
", name='" + name + '\'' +
", weight=" + weight +
", color='" + color + '\'' +
", hardness=" + hardness +
", transparency=" + transparency +
... |
33db0fe9-f1bd-4112-9c9d-a6931f9fb021 | public PreciousStone() {
this.name = "no name";
this.rarity = false;
} |
a6a05bbf-4d99-4902-a4d5-068bfd1b6687 | public PreciousStone(String name) {
this.name = name;
this.rarity = false;
} |
1c20877a-0460-4ec8-8aa8-7c8422bab24d | public PreciousStone(String name, boolean rarity) {
this.name = name;
this.rarity = rarity;
} |
3fdf4ea1-0d98-4572-890c-edf7ffa667d9 | public void setName(String name) {
if (null == name) {
this.name = "no name";
} else {
this.name = name;
}
} |
5766bb6a-d22c-49da-8f33-abd4367b5d87 | public String getName() {
return this.name;
} |
b367ed5b-16bd-4405-b86b-12244c7c61b1 | public void setRarity(boolean rarity) {
this.rarity = rarity;
} |
bd0eb727-3ac3-4802-ab7e-0ccf80bcf7cd | public boolean isRarity() {
return this.rarity;
} |
a3c5561b-96ca-4d31-8488-198ade456717 | @Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(getClass().getName());
builder.append("\nWeight: ").append(this.getWeight());
builder.append("\nColor: ").append(this.getColor().toString());
builder.append("\nHardness: ").append... |
e7356c26-ab41-45f9-93d1-5e406688f129 | public Topaz() {
this.form = Form.UNDEFINED;
this.size = 0;
} |
8c34e23e-ef41-43ca-98ec-81596833740d | public Topaz(Form form) {
this.form = form;
this.size = 0;
} |
81c200f5-cef5-47be-9662-93befb668121 | public Topaz(Form form, int size) {
this.form = form;
this.size = size;
} |
119ba954-4ebf-4fa6-a67e-a6545f8e1e3d | public void setForm(Form form) {
this.form = form;
} |
f538f555-3ca1-4348-9c44-63bd0a1c9676 | public Form getForm() {
return this.form;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.