Autor Beitrag
beastofchaos
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 247
Erhaltene Danke: 4



BeitragVerfasst: Mo 04.04.11 20:03 
Hallo Leute,
Ich arbeite an einem Programm, bei dem Artikel-Stückzahlen eingegeben werden und ich gebe danach den Gesamtpreis aus. Dabei besteht der Unterschied von Rabatten. Ab 50 gibts 5%, ab 100 7,5% und ab 500 10% Rabatt.
Jetzt will ich das ganze in einer case...of-Schleife einbringen. Leider lässt sich das ganze nicht so geplant ausführen in einer case...of-Schleife. Es sieht wie folgt aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
case Anzahl of
  <50: Rabatt := 0;
  >=50 and <100: Rabatt := 5;
  .
  .
  .


Leider ist das so nicht verwirklichbar. Weiß einer von euch, wie ich (statt einzelner Integer-Zahlen) Integer-"Bereiche" abfragen kann?

Grüße, Thomas
Tankard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Administrator
Beiträge: 217
Erhaltene Danke: 96



BeitragVerfasst: Mo 04.04.11 20:06 
probier mal mit

50..100,555: begin
end;


da wird dann auf bereich 50 bis 100 und 555 geprueft.
beastofchaos Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 247
Erhaltene Danke: 4



BeitragVerfasst: Mo 04.04.11 20:42 
Genial, Danke ;)
Tankard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Administrator
Beiträge: 217
Erhaltene Danke: 96



BeitragVerfasst: Mo 04.04.11 21:38 
aehm noch kurze anmerkung. die bereichsenden sind mit drin. bei dir muesste also nur bis 99 gehen.
beastofchaos Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 247
Erhaltene Danke: 4



BeitragVerfasst: Mo 04.04.11 23:50 
user profile iconTankard hat folgendes geschrieben Zum zitierten Posting springen:
aehm noch kurze anmerkung. die bereichsenden sind mit drin. bei dir muesste also nur bis 99 gehen.

Hab ich auch gedacht und entsprechend geschrieben ;)
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Di 05.04.11 07:36 
Was machst Du, wenn die Rabattstaffelung mal geändert wird? Programm neu kompilieren?
ausblenden volle Höhe Delphi-Quelltext
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:
Type
  TRabatt = Record
    MindestmengeMenge : Integer;
    Preis : Currency;
  End;

Function RabattpreisProStueckBeiAbnahmeVon(Artikelmenge : Integer) : Currency;
Var
  i : Integer;

Begin
  for i:=0 to High (RabattPreise) do
    If RabattPreise[i].Mindestmenge <= Artikelmenge Then begin
      Result := RabattPreise[i].Preis;
      Exit;
    End;
End;

Procedure InitialisiereRabattstaffelung;
Begin
  // Anzahl und inhalt der Einträge ist beliebig, 
  // Erster Eintrag muss Einzelpreis enthalten, 
  // Einträge sind aufsteigend nach Mindestmenge sortiert.
  //
  // Die Staffelung kann auch in einer Datei / Datenbank liegen
  //
  RabattPreise[0].Mindestmenge := 1// Einzelpreis ist immer der 1.Eintrag
  RabattPreise[0].Preis := 1.50;

  RabattPreise[1].Mindestmenge := 50// Ab 50 Stück ...
  RabattPreise[1].Preis := 1.48;

  RabattPreise[2].Mindestmenge := 100// Ab 100 Stück ...
  RabattPreise[2].Preis := 1.45;
  ...
End;

_________________
Na denn, dann. Bis dann, denn.