Skip to content

Instantly share code, notes, and snippets.

/**
* Based on code by Caroline Dunn: https://github.com/carolinedunn/pico-weather-station
**/
#include <stdio.h>
#include <math.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include <string.h>
const uint LED_PIN = PICO_DEFAULT_LED_PIN;
@eleanor-em
eleanor-em / TvNetwork.java
Created March 31, 2020 04:17
TvNetwork example with Show class for SWEN20003.
class Show {
private String name;
private String airTime;
public Show(String name, int hour, int minute) {
if (hour < 0 || hour > 24) {
System.out.println("warning: invalid hour: " + hour);
}
if (minute < 0 || minute > 59) {
System.out.println("warning: invalid minute: " + minute);
@eleanor-em
eleanor-em / Program.java
Created October 10, 2019 00:15
Week 10 example
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.PriorityQueue;
class WaitTimeComparator implements Comparator<Customer> {
@Override
public int compare(Customer c1, Customer c2) {
// if (c1.waitTime > c2.waitTime) {
// return -1;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
class TooFewColumnsException extends Exception {
public TooFewColumnsException(int row) {
super("Error reading CSV file at row " + row + ": too few columns");
}
}
@eleanor-em
eleanor-em / getTools.java
Created September 12, 2019 00:57
getTools example for the Recipe class
int size = 0;
for (Food f : food) {
size += f.getTools().length;
}
Tool[] tools = new Tool[size];
int i = 0;
for (Food f : food) {
for (Tool t : f.getTools()) {
tools[i++] = t;
public class Program {
public static void main(String[] args) {
Shape[] shapes = new Shape[3];
sgihapes[0] = new Circle(0, 0, 1);
shapes[1] = new Rectangle(0, 0, 2, 1);
shapes[2] = new Circle(1, 1, 1);
for (Shape shape : shapes) {
System.out.println(shape.getArea());
}
public class Program {
public static void main(String[] args) {
Shape[] shapes = new Shape[3];
sgihapes[0] = new Circle(0, 0, 1);
shapes[1] = new Rectangle(0, 0, 2, 1);
shapes[2] = new Circle(1, 1, 1);
for (Shape shape : shapes) {
System.out.println(shape.getArea());
}
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyWQXiYiP0Pg/IyMTn/9yvtmZw8aIde9RufiuInnn8wp1PYb8tHo8ocTA2ycd/Orv+zKLsjq4VRFsFQJ+4heIvist56wwKmhs6XUU5nVMZvFm2P0RTwY9N8AeuQYK8xHAjrdchS34lQlxi7nQcZx/RhH8vseuhyrVX80sI96TPirYXTjQusuNIKLcHk3+SqTUQqp2q3yy4x5UNJe69rcWUNUdboZSV7726VZZze8gwnEPUYGJrfOsUTomeTTFI8Qe3OTH7NZCRJ6NkIQr+6UrRYcq8vlMIlAGERGCzRG0/qq07dCnU2a6biwJX5Tzr1gNDEW/R9Ah3NdcxPHFybRvX eleanor@Athena
@eleanor-em
eleanor-em / Main.java
Created May 8, 2019 02:10
PriorityQueue example
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Comparator;
class Customer {
private int timeOnHold;
public Customer(int timeOnHold) {
this.timeOnHold = timeOnHold;
}
@eleanor-em
eleanor-em / Main.java
Created May 7, 2019 05:23
Example of using HashMap in Java.
import java.util.Arrays;
import java.util.HashMap;
class Ingredient {
public final String name;
public Ingredient(String name) {
this.name = name;
}