Autor Beitrag
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mo 10.04.06 19:09 
Jepp..Deswagen hab ich auch nicht gesendent Code ist mit allem drum und dran 56 Zeilen.
Was machen wir nu.

Edit: vielleicht soviel:
3 Variablen; 5 Labels; 1 Button, 1 if Then else Abfrage.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 10.04.06 19:19 
:tongue: Meiner ist nur 54 Zeilen lang :tongue: ;)
Wofür die dritte Variable? Ich habe nur drei Labels benutzt
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
type
  TForm1 = class(TForm)
    Button1: TButton;
    lziffer1: TLabel;
    lziffer2: TLabel;
    lergebnis: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  ziffer1,ziffer2 : real;

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
reborn
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 10.04.06 19:21 
ich brauch es zwar für die schule,muss aber daran noch weiterarbeiten und weitere sachen einfügen,das problem war nur dies in oop zu tun von dem ich keine ahnung hab,weil ich halt die schule gewechselt hab. jedem ist freigestellt mir zu helfen, keiner wird gezwungen!
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 10.04.06 19:24 
Na dann helfe ich dir jetzt.
Versuche erstmal, einen Algorithmus in Pseudocode zu entwerfen.
Damit ist gemeint, dass du notierst, was gemacht werden soll. Allerdings nicht in Delphi Language sondern mit deutschen Worten (statt: if zahl1=5 z.B. wenn zahl1 gleich 5 ist).

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mo 10.04.06 19:27 
ausblenden Delphi-Quelltext
1:
2:
Label4.Caption:='/';
Label5.Caption:='=';

Ansonsten siehst genauso so aus.
Nen Paar Leerzeilen entfernt und schon sind nur noch 51 :P

Ich Habs ja weiter oben auch schon mit Pseudo code versucht:

Eine Zufällige Zahl a geteilt durch eine zufällige Zahl b =ergebniss.
Wenn a =0 oder b=0 dann Fehlermeldung ansonsten.ergebniss berechenen.


Zuletzt bearbeitet von der Berliner am Mo 10.04.06 19:31, insgesamt 1-mal bearbeitet
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 10.04.06 19:30 
Das geht auch anders: ;)
ausblenden Delphi-Quelltext
1:
2:
//lergebnis ist das Label, wo steht: 5 durch 2,5 ist gleich 2
lergebnis.caption:=floattostr(ziffer1)+' geteilt durch '+floattostr(ziffer2) +' ist gleich '+floattostr(ziffer1/ziffer2);

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 10.04.06 19:33 
So - er sagt, er hätte es auch selber hinbekommen:
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:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    lziffer1: TLabel;
    lziffer2: TLabel;
    lergebnis: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  ziffer1,ziffer2 : real;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
randomize;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ziffer1:=random(1000)+1;
  ziffer2:=random(1000)+1;
  lziffer1.caption:='Ziffer1: '+floattostr(ziffer1);
  lziffer2.caption:='Ziffer2: '+floattostr(ziffer2);
  try
   lergebnis.caption:=floattostr(ziffer1)+' geteilt durch '+floattostr(ziffer2) +' ist gleich '+floattostr(ziffer1/ziffer2);
   lergebnis.show;
  except
    messagedlg('Division durch Null!',mterror,[mbok],0)
  end;
end;



end.

Die Frage ist, inwieweit man hier die Objektorientierte Programmierung einsetzen kann :nixweiss: Kann mir das mal jemand sagen??? :flehan:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mo 10.04.06 19:34 
Ok..Ich geb mich geschlagen. :(
Ich habs nen bischen einfacher gestrickt:
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:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    LZahl1: TLabel;
    LZahl2: TLabel;
    LErgebniss: TLabel;
    Label4: TLabel;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;
var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
 Randomize;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  z1,z2,Ergebniss:Real;
begin
z1:=Random(500);
Z2:=Random(500);
ergebniss:=z1/z2;
LZahl1.Caption:=FloatToStr(z1);
Lzahl2.Caption:=FloatToStr(z2);
 If (Z1=0) or (Z2=0)then
 Begin
  showMessage('Divison durch Null !'+Chr(13)+'Starten Sie nochmal.');
 end
 else
  LErgebniss.Caption:=FloatToStr(Ergebniss);
 end;
end.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 10.04.06 19:36 
user profile iconder Berliner hat folgendes geschrieben:
Ok..Ich geb mich geschlagen. :(

Im Bezug auf was jetzt?
Edit: Ich hatte zuerst auch eine if-Abfrage. Aber reborn meinte, aufgrund der OOP sollte man eine try-except-Fehlerbehandlung nehmen. Ansonsten würde ich auch die if-Abfrage bevorzugen ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot


Zuletzt bearbeitet von Marco D. am Mo 10.04.06 19:38, insgesamt 1-mal bearbeitet
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mo 10.04.06 19:38 
user profile iconMarco D. hat folgendes geschrieben:
user profile iconder Berliner hat folgendes geschrieben:
Ok..Ich geb mich geschlagen. :(

Im Bezug auf was jetzt?

Das das mit den Labels Aauch anders geht.

Also ich Krieg das mit OOP nich auf die Reihe.
reborn
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 10.04.06 19:45 
naja trotzdem danke an euch, ich werds meinem lehrer sagen! die lösung werde ich schnellstmöglich reinposten,ich werd mich dann mal selber da reinknien :-(
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mo 10.04.06 19:46 
Wie die Lösung?
Du Hast doch jetzt Zwei Lösungungen oder ?
Definier doch mal OOP.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 10.04.06 19:50 
Naja, sein Lehrer hat gesagt, sie sollen das Problem unter Zuhilfenahme der OOP lösen. Aber ich finde, da kann man dies nicht so recht anwenden. Und wenn der Lehrer meint, dass man das doch kann, dann soll reborn diese Lehrer-Variante mal posten. So ist das gemeint ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mo 10.04.06 19:52 
Aja..na dann harren wir der Dinge die da kommen.
Gruß
reborn
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 10.04.06 19:59 
obwohl 1 frage hätt ich noch! mit der oop könnte man doch diesen bruch,der daraus kommt noch kürzen und erweitern oder?dies würde doch wieder sinnvoll werden?
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 10.04.06 20:03 
Das ist ein Dezimalbruch. Was willst du da kürzen/erweitern? Du kannst höchstens auf- und abrunden.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mo 10.04.06 20:07 
Also ich hab jetzt mal nageschaut:
Zitat:


Objektorientiertes Programmieren
engl.: Object-oriented programming

Themengebiet: Allgemeine Informatik


Bedeutung:
Moderne Programmiermethode, die von den konkreten, inhaltlichen Problemen ausgeht und nicht von einer theoretischen EDV-Systematik. Es wird nicht mehr zwischen Daten (passiven Datenstrukturen) und Methoden (aktiven Funktionen) unterschieden. Ein Objekt besteht hierbei aus einem Datensatz und einer Anzahl von Anweisungen, die es ausführen kann. Ein Objekt enthält also mit seinen Daten und Funktionen immer alles, was für eine bestimmte Aufgabe nötig ist. Objektorientierte Programmsprachen (z.B. C++, Java, Smalltalk, Eiffel) unterstützen den objektorientierten Softwareentwurf. Zentrale Konzepte sind die Vererbung, die Kapselung und die Polymorphie.


Glaube nicht das man die Aufgabenstellung damit in zusammenhang bringen kann.
reborn
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 10.04.06 20:08 
stimmt fehler von mir! nehmen wir an wir legen diesen in einen echten bruch um^^
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mo 10.04.06 20:36 
:autsch: Seit Beginn des Threads habe ich mich gefragt, was man denn daran in Objekten verpacken sollte.

Naja, wenn mit echten Brüchen gerechnet werden soll, macht das ja sehr viel mehr Sinn. So ein Bruch besteht aus Zähler und Nenner, also brauchen wir diese beiden Zahlen, die beide ganzzahlig sind. Den Bruch muss man irgendwie geschickt ausgeben können. Da hätten wir schonmal eine Methode. Bliebe noch das Teilen, noch 'ne Methode. So, eine schicke Bruch-Klasse:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
TBruch = class
  protected
    Zaehler: Integer;
    Nenner: Integer;
  public
    constructor Create(aZaehler, aNenner: Integer);
    function ToString: String;
    procedure Dividiere(aBruch: TBruch);
end;
Das ist nur die Klassendeklaration. Implementieren darfst du jetzt selber. Innerhalb der Methoden hast du Zugriff auf die Variablen Zaehler und Nenner des Bruchen, die solltest du verwenden. Im Konstruktor wird der Bruch mit Werten initialisiert, die beiden Parameter solltest du also in die Variablen retten. Bei ToString solltest du darauf achten, daß es gemischte Brüche gibt, also der Zähler ein Vielfaches vom Nenner sein kann. Das Dividieren geht grundschulartig: Man teilt durch einen Bruch, indem man mit seinem Kehrwert multipliziert.
Das kann man bei Bedarf auch noch um die Methode Kuerze ergänzt werden.
Wie du diese Methoden nun implementierst, findest du in jedem schlechteren Howto zu Klassen, oder hier.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mo 10.04.06 20:39 
Soll das hier eigentlich immer noch ein "Jobangebot" sein? Ich würde nämlich dazu tendieren, das Topic in die entsprechende Sparte zu verschieben ;)

AXMD
Ist die Frage beantwortet? Das Problem gelöst?

Dann klicke hier, um das Thema entsprechend zu markieren!