-
Notifications
You must be signed in to change notification settings - Fork 3
/
ListinoLineare.java
46 lines (35 loc) · 1.45 KB
/
ListinoLineare.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Copyright 2022 Massimo Santini
This file is part of "Programmazione 2 @ UniMI" teaching material.
This is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This material is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this file. If not, see <https://www.gnu.org/licenses/>.
*/
import java.util.Map;
/**
* Classe concreta che implementa un listino in cui il prezzo totale di <samp>n</samp> giocattoli di
* un dato tipo è pari a <samp>n</samp> volte il prezzo unitario di tale giocattolo.
*/
public class ListinoLineare extends AbstracListinoUnitario {
/**
* Costruisce un listino a partire da una mappa tra giocattoli e prezzi unitari.
*
* @param prezzoUnitario la mappa.
* @see AbstracListinoUnitario
*/
public ListinoLineare(final Map<Giocattolo, Integer> prezzoUnitario) {
super(prezzoUnitario);
}
@Override
public int prezzo(final int num, final Giocattolo giocattolo) {
if (num <= 0) throw new IllegalArgumentException("Il numero deve essere positivo");
return prezzoUnitario(giocattolo) * num;
}
}