Search in sources :

Example 1 with Date

use of com.google.api.ads.admanager.jaxws.v202105.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 com.google.api.ads.admanager.jaxws.v202105.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 com.google.api.ads.admanager.jaxws.v202105.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 com.google.api.ads.admanager.jaxws.v202105.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 com.google.api.ads.admanager.jaxws.v202105.Date in project googleads-java-lib by googleads.

the class Pql method createValue.

/**
 * Creates a {@link Value} from the value i.e. a {@link TextValue} for a value of type {@code
 * String}, {@link BooleanValue} for type {@code Boolean}, {@link NumberValue} for type {@code
 * Double}, {@code Long}, or {@code Integer}, and {@link DateTimeValue} for type {@link DateTime}.
 * If the value is a {@code Value}, the value is returned. If the value is {@code null}, an empty
 * {@link TextValue} is returned.
 *
 * @param value the value to convert
 * @return the constructed value of the appropriate type
 * @throws IllegalArgumentException if value cannot be converted
 */
public static Value createValue(Object value) {
    if (value instanceof Value) {
        return (Value) value;
    } else if (value == null) {
        return new TextValue();
    } else {
        if (value instanceof Boolean) {
            BooleanValue booleanValue = new BooleanValue();
            booleanValue.setValue((Boolean) value);
            return booleanValue;
        } else if (value instanceof Double || value instanceof Long || value instanceof Integer) {
            NumberValue numberValue = new NumberValue();
            numberValue.setValue(value.toString());
            return numberValue;
        } else if (value instanceof String) {
            TextValue textValue = new TextValue();
            textValue.setValue((String) value);
            return textValue;
        } else if (value instanceof DateTime) {
            DateTimeValue dateTimeValue = new DateTimeValue();
            dateTimeValue.setValue((DateTime) value);
            return dateTimeValue;
        } else if (value instanceof Date) {
            DateValue dateValue = new DateValue();
            dateValue.setValue((Date) value);
            return dateValue;
        } else if (value instanceof Targeting) {
            TargetingValue targetingValue = new TargetingValue();
            targetingValue.setValue((Targeting) value);
            return targetingValue;
        } else if (value instanceof Set<?>) {
            SetValue setValue = new SetValue();
            Set<Value> values = new LinkedHashSet<Value>();
            for (Object entry : (Set<?>) value) {
                validateSetValueEntryForSet(createValue(entry), values);
                values.add(createValue(entry));
            }
            setValue.getValues().addAll(values);
            return setValue;
        } else {
            throw new IllegalArgumentException("Unsupported Value type [" + value.getClass() + "]");
        }
    }
}
Also used : Set(java.util.Set) ResultSet(com.google.api.ads.admanager.jaxws.v202105.ResultSet) LinkedHashSet(java.util.LinkedHashSet) DateTimeValue(com.google.api.ads.admanager.jaxws.v202105.DateTimeValue) Targeting(com.google.api.ads.admanager.jaxws.v202105.Targeting) DateTime(com.google.api.ads.admanager.jaxws.v202105.DateTime) Date(com.google.api.ads.admanager.jaxws.v202105.Date) NumberValue(com.google.api.ads.admanager.jaxws.v202105.NumberValue) TextValue(com.google.api.ads.admanager.jaxws.v202105.TextValue) DateValue(com.google.api.ads.admanager.jaxws.v202105.DateValue) BooleanValue(com.google.api.ads.admanager.jaxws.v202105.BooleanValue) NumberValue(com.google.api.ads.admanager.jaxws.v202105.NumberValue) BooleanValue(com.google.api.ads.admanager.jaxws.v202105.BooleanValue) Value(com.google.api.ads.admanager.jaxws.v202105.Value) SetValue(com.google.api.ads.admanager.jaxws.v202105.SetValue) DateTimeValue(com.google.api.ads.admanager.jaxws.v202105.DateTimeValue) TargetingValue(com.google.api.ads.admanager.jaxws.v202105.TargetingValue) DateValue(com.google.api.ads.admanager.jaxws.v202105.DateValue) TextValue(com.google.api.ads.admanager.jaxws.v202105.TextValue) TargetingValue(com.google.api.ads.admanager.jaxws.v202105.TargetingValue) SetValue(com.google.api.ads.admanager.jaxws.v202105.SetValue)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)16 Set (java.util.Set)8 Before (org.junit.Before)8 Test (org.junit.Test)8 Date (edu.princeton.cs.algs4.Date)7 Date (com.google.api.ads.admanager.axis.v202108.Date)5 Date (com.google.api.ads.admanager.axis.v202111.Date)5 Date (com.google.api.ads.admanager.axis.v202202.Date)5 BooleanValue (com.google.api.ads.admanager.axis.v202105.BooleanValue)3 Date (com.google.api.ads.admanager.axis.v202105.Date)3 DateTimeValue (com.google.api.ads.admanager.axis.v202105.DateTimeValue)3 DateValue (com.google.api.ads.admanager.axis.v202105.DateValue)3 BooleanValue (com.google.api.ads.admanager.axis.v202108.BooleanValue)3 DateTimeValue (com.google.api.ads.admanager.axis.v202108.DateTimeValue)3 DateValue (com.google.api.ads.admanager.axis.v202108.DateValue)3 NumberValue (com.google.api.ads.admanager.axis.v202108.NumberValue)3 SetValue (com.google.api.ads.admanager.axis.v202108.SetValue)3 TargetingValue (com.google.api.ads.admanager.axis.v202108.TargetingValue)3 TextValue (com.google.api.ads.admanager.axis.v202108.TextValue)3 NumberValue (com.google.api.ads.admanager.axis.v202105.NumberValue)2