Search in sources :

Example 1 with Date

use of edu.princeton.cs.algs4.Date in project algorithms-sedgewick-wayne by reneargento.

the class Exercise13 method main.

public static void main(String[] args) {
    Date date = new Date(8, 3, 2016);
    Exercise13 transaction = new Exercise13("Rene", date, 500);
    StdOut.println(transaction);
    StdOut.println("Expected: Rene spent 500.0 on 8/3/2016");
}
Also used : Date(edu.princeton.cs.algs4.Date)

Example 2 with Date

use of edu.princeton.cs.algs4.Date in project algorithms-sedgewick-wayne by reneargento.

the class Exercise14 method main.

public static void main(String[] args) {
    Date date = new Date(8, 3, 2016);
    Exercise14 transaction1 = new Exercise14("Rene", date, 500);
    Exercise14 transaction2 = new Exercise14("Rene", date, 500);
    Exercise14 transaction3 = new Exercise14("Argento", date, 600);
    Exercise14 transaction4 = transaction3;
    StdOut.println("Equals 1: " + transaction1.equals(transaction2) + " Expected: true");
    StdOut.println("Equals 2: " + transaction2.equals(transaction1) + " Expected: true");
    StdOut.println("Equals 3: " + transaction1.equals(transaction3) + " Expected: false");
    StdOut.println("Equals 4: " + transaction3.equals(transaction4) + " Expected: true");
}
Also used : Date(edu.princeton.cs.algs4.Date)

Example 3 with Date

use of edu.princeton.cs.algs4.Date in project algorithms-sedgewick-wayne by reneargento.

the class Exercise33_RandomTransactions method generateRandomTransactions.

private Exercise21_ComparableTransactions[] generateRandomTransactions(int numberOfObjects) {
    Exercise21_ComparableTransactions[] transactions = new Exercise21_ComparableTransactions[numberOfObjects];
    for (int i = 0; i < numberOfObjects; i++) {
        String who = "Client " + (i + 1);
        int month = StdRandom.uniform(12) + 1;
        int maxDay = month == 2 ? 28 : 30;
        int day = StdRandom.uniform(maxDay) + 1;
        int year = StdRandom.uniform(1900, 2018);
        Date date = new Date(month, day, year);
        double amount = (double) Math.round(StdRandom.uniform(0.0, 1000000.0) * 100) / 100;
        Exercise21_ComparableTransactions transaction = new Exercise21_ComparableTransactions(who, date, amount);
        transactions[i] = transaction;
    }
    return transactions;
}
Also used : Date(edu.princeton.cs.algs4.Date) Exercise21_ComparableTransactions(chapter2.section1.Exercise21_ComparableTransactions)

Example 4 with Date

use of edu.princeton.cs.algs4.Date in project algorithms-sedgewick-wayne by reneargento.

the class Exercise25_HashCache method main.

public static void main(String[] args) {
    Exercise25_HashCache hashCache = new Exercise25_HashCache();
    Transaction transaction = hashCache.new Transaction("Person 1", new Date(1, 10, 5), 1000);
    StdOut.println(transaction.hashCode() + " Expected: Cache miss");
    StdOut.println(transaction.hashCode() + " Expected: Cache hit");
    StdOut.println(transaction.hashCode() + " Expected: Cache hit");
}
Also used : Date(edu.princeton.cs.algs4.Date)

Example 5 with Date

use of edu.princeton.cs.algs4.Date in project algorithms-sedgewick-wayne by reneargento.

the class Exercise22 method main.

public static void main(String[] args) {
    Exercise22 exercise22 = new Exercise22();
    Point2D point2D = exercise22.new Point2D(20, 13);
    StdOut.println(point2D.hashCode());
    Interval interval = exercise22.new Interval(1, 999);
    StdOut.println(interval.hashCode());
    Interval1D interval1D1 = new Interval1D(10.2, 30.20);
    Interval1D interval1D2 = new Interval1D(2, 1000);
    Interval2D interval2D = exercise22.new Interval2D(interval1D1, interval1D2);
    StdOut.println(interval2D.hashCode());
    Date date = exercise22.new Date(18, 4, 1989);
    StdOut.println(date.hashCode());
}
Also used : Interval1D(edu.princeton.cs.algs4.Interval1D)

Aggregations

Date (edu.princeton.cs.algs4.Date)7 Exercise21_ComparableTransactions (chapter2.section1.Exercise21_ComparableTransactions)1 In (edu.princeton.cs.algs4.In)1 Interval1D (edu.princeton.cs.algs4.Interval1D)1 Queue (edu.princeton.cs.algs4.Queue)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 Test (org.junit.Test)1 ReverseByteArrayOutputStream (org.openmuc.jasn1.ber.ReverseByteArrayOutputStream)1 BerEmbeddedPdv (org.openmuc.jasn1.ber.types.BerEmbeddedPdv)1 BerInteger (org.openmuc.jasn1.ber.types.BerInteger)1 BerVisibleString (org.openmuc.jasn1.ber.types.string.BerVisibleString)1 ChildInformation (org.openmuc.jasn1.compiler.modules.module1.ChildInformation)1 Date (org.openmuc.jasn1.compiler.modules.module1.Date)1 MyBitString (org.openmuc.jasn1.compiler.modules.module1.MyBitString)1 MyDate1 (org.openmuc.jasn1.compiler.modules.module1.MyDate1)1 MyInt (org.openmuc.jasn1.compiler.modules.module1.MyInt)1 MyInt2 (org.openmuc.jasn1.compiler.modules.module1.MyInt2)1 Name (org.openmuc.jasn1.compiler.modules.module1.Name)1 PersonnelRecord (org.openmuc.jasn1.compiler.modules.module1.PersonnelRecord)1