I'm studying java and I need to do a code with this: Create a constructor, and if the date is monday, the variable total will have 10% of discount.
But I'm getting error when I put a date in my main, and have no idea how create this boolean of local date "monday". Can someone help me?
My code:
package pedido;
import java.time.DayOfWeek;
import java.time.LocalDate;
public class pedido {
private int numero;
private LocalDate datapedido;
private double quantidade, valor, total;
private boolean sunday;
public pedido(int m, LocalDate j, double p, double k) {
this.numero = m;
this.datapedido = j;
this.quantidade = p;
this.valor = k;
}
public void totalpedido() {
if(sunday == true) {
total = (this.valor * this.quantidade) * 0.9;
System.out.printf("Por hoje ser domingo o total ficou: R$%.2f", total);
}
if(sunday == false) {
total = (this.valor * this.quantidade);
System.out.printf("O total ficou: %.2f", total);
}
}
}
and the main:
package pedido;
import java.time.DayOfWeek;
import java.time.LocalDate;
public class program {
public static void main(String[] args) {
pedido p1 = new pedido(111, 2021-09-26, 2, 36.50);
p1.totalpedido();
pedido p2 = new pedido(222, 2021-09-23, 1, 13.25);
p2.totalpedido();
}
}
Errors:
Multiple markers at this line - The constructor pedido(int, int, int, double) is undefined - The literal 09 of type int is out of range