Skip to content

Commit 45db751

Browse files
committed
calc
1 parent 0077b48 commit 45db751

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+3695
-0
lines changed

Counter.class

2.07 KB
Binary file not shown.

Counter.ctxt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=void\ act()
4+
comment1.params=cyfra
5+
comment1.target=void\ dodajCyfre(int)
6+
comment1.text=\r\n\ "wynik"\ przyjmuje\ warto\u015B\u0107\ na\ podstawie\ klawisza\ operator\u00F3w\:\r\n\ 1\ -\ dodawanie\r\n\ 2\ -\ odejmowanie\r\n\ 3\ -\ mno\u017Cenie\r\n\ 4\ -\ dzielenie\r\n\ P\u00F3\u017Aniej\ wykorzystany\ jest\ po\ kliknieciu\ znaku\ r\u00F3wno\u015Bci.\r\n\ Sam\ spos\u00F3b\ ustawiania\ liczb\ nie\ wymaga\ t\u0142umaczenia\ ;-)\r\n
7+
comment2.params=wynik\ operator
8+
comment2.target=void\ ustawZnak(int,\ char)
9+
comment3.params=
10+
comment3.target=void\ razem()
11+
comment4.params=
12+
comment4.target=void\ kasuj()
13+
numComments=5

Counter.java

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import greenfoot.*;
2+
import java.awt.*;
3+
4+
public class Counter extends Actor
5+
{
6+
int liczba1=0;
7+
int liczba2=0;
8+
int wynik=0;
9+
float iloraz;
10+
int dzialanie;
11+
String pierwsza="";
12+
String druga="";
13+
char operator=' ';
14+
String koniec="";
15+
16+
public void act()
17+
{
18+
/*Dwa sposoby na zamianę liczby na String. Pierwszy zastosowany w "if"
19+
* pierwsza=String.valueOf(liczba1); //sposób 2 też działa
20+
*/
21+
if (liczba1!=0)
22+
{
23+
pierwsza=Integer.toString(liczba1);
24+
}
25+
26+
if(liczba2!=0)
27+
{
28+
druga=Integer.toString(liczba2);
29+
}
30+
GreenfootImage klikaj=new GreenfootImage(pierwsza +operator +druga +koniec, 36, Color.RED, null);
31+
setImage (klikaj);
32+
}
33+
34+
/*
35+
* "wynik" przyjmuje wartość na podstawie klawisza operatorów:
36+
* 1 - dodawanie
37+
* 2 - odejmowanie
38+
* 3 - mnożenie
39+
* 4 - dzielenie
40+
* Później wykorzystany jest po kliknieciu znaku równości.
41+
* Sam sposób ustawiania liczb nie wymaga tłumaczenia ;-)
42+
*/
43+
44+
public void dodajCyfre(int cyfra)
45+
{
46+
if (wynik==0)
47+
{
48+
if(liczba1==0)
49+
{
50+
liczba1=cyfra;
51+
}
52+
else
53+
{
54+
liczba1=liczba1*10+cyfra;
55+
}
56+
}
57+
else
58+
{
59+
if(liczba2==0)
60+
{
61+
liczba2=cyfra;
62+
}
63+
else
64+
{
65+
liczba2=liczba2*10+cyfra;
66+
}
67+
}
68+
}
69+
70+
public void ustawZnak(int wynik, char operator)
71+
{
72+
this.wynik = wynik;
73+
this.operator = operator;
74+
}
75+
76+
public void razem()
77+
{
78+
if(wynik==0)
79+
{
80+
koniec = "Hmm...";
81+
}
82+
else if(wynik==4)
83+
{
84+
iloraz= (float)liczba1 / (float)liczba2;
85+
koniec = "= " +Float.toString(iloraz);
86+
}
87+
else {
88+
if(wynik==1)
89+
{
90+
dzialanie=liczba1 + liczba2;
91+
}
92+
else if (wynik==2)
93+
{
94+
dzialanie=liczba1 - liczba2;
95+
}
96+
else if (wynik==3)
97+
{
98+
dzialanie=liczba1 * liczba2;
99+
}
100+
koniec = "= " + Integer.toString(dzialanie);
101+
}
102+
}
103+
104+
105+
public void kasuj()
106+
{
107+
liczba1=0;
108+
liczba2=0;
109+
wynik=0;
110+
pierwsza="";
111+
druga="";
112+
operator=' ';
113+
koniec="";
114+
}
115+
116+
}

Cyfra.class

643 Bytes
Binary file not shown.

Cyfra.ctxt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=void\ act()
4+
numComments=1

Cyfra.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import greenfoot.*;
2+
3+
/**
4+
* Write a description of class Cyfra here.
5+
*
6+
* @author (your name)
7+
* @version (a version number or a date)
8+
*/
9+
public class Cyfra extends Actor
10+
{
11+
int cyfraKliknieta;
12+
public void act()
13+
{
14+
Space swiat=(Space) getWorld();//wywołanie świata
15+
16+
if(Greenfoot.mouseClicked(this)){
17+
swiat.licznik.dodajCyfre(this.cyfraKliknieta);
18+
}
19+
}
20+
}

Cztery.class

276 Bytes
Binary file not shown.

Cztery.ctxt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=Cztery()
4+
numComments=1

Cztery.java

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import greenfoot.*;
2+
3+
/**
4+
* Write a description of class Cztery here.
5+
*
6+
* @author (your name)
7+
* @version (a version number or a date)
8+
*/
9+
public class Cztery extends Cyfra
10+
{
11+
public Cztery() {
12+
cyfraKliknieta = 4;
13+
}
14+
15+
}

Dwa.class

267 Bytes
Binary file not shown.

Dwa.ctxt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=Dwa()
4+
numComments=1

Dwa.java

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import greenfoot.*;
2+
3+
4+
/**
5+
* Write a description of class ClickableButton here.
6+
*
7+
* @author (your name)
8+
* @version (a version number or a date)
9+
*/
10+
public class Dwa extends Cyfra
11+
{
12+
public Dwa(){
13+
cyfraKliknieta = 2;
14+
}
15+
}

Dzialanie.class

683 Bytes
Binary file not shown.

Dzialanie.ctxt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=void\ act()
4+
numComments=1

Dzialanie.java

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import greenfoot.*;
2+
3+
/**
4+
* Write a description of class Dzialanie here.
5+
*
6+
* @author (your name)
7+
* @version (a version number or a date)
8+
*/
9+
public class Dzialanie extends Actor
10+
{
11+
int wynik;
12+
char operator;
13+
14+
public void act()
15+
{
16+
Space swiat=(Space) getWorld();//wywołanie świata
17+
18+
if(Greenfoot.mouseClicked(this))
19+
{
20+
swiat.licznik.ustawZnak(this.wynik, this.operator);
21+
}
22+
23+
}
24+
}

Dziewiec.class

283 Bytes
Binary file not shown.

Dziewiec.ctxt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=Dziewiec()
4+
comment0.text=\r\n\ Act\ -\ do\ whatever\ the\ Dziewiec\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
5+
numComments=1

Dziewiec.java

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import greenfoot.*;
2+
3+
/**
4+
* Write a description of class Dziewiec here.
5+
*
6+
* @author (your name)
7+
* @version (a version number or a date)
8+
*/
9+
public class Dziewiec extends Cyfra
10+
{
11+
/**
12+
* Act - do whatever the Dziewiec wants to do. This method is called whenever
13+
* the 'Act' or 'Run' button gets pressed in the environment.
14+
*/
15+
public Dziewiec()
16+
{
17+
cyfraKliknieta = 9;
18+
}
19+
}

Jeden.class

273 Bytes
Binary file not shown.

Jeden.ctxt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=Jeden()
4+
numComments=1

Jeden.java

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import greenfoot.*;
2+
3+
public class Jeden extends Cyfra
4+
{
5+
public Jeden(){
6+
cyfraKliknieta = 1;
7+
}
8+
}

Kasuj.class

650 Bytes
Binary file not shown.

Kasuj.ctxt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=void\ act()
4+
comment0.text=\r\n\ Act\ -\ do\ whatever\ the\ Kasuj\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
5+
numComments=1

Kasuj.java

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import greenfoot.*;
2+
3+
/**
4+
* Write a description of class Kasuj here.
5+
*
6+
* @author (your name)
7+
* @version (a version number or a date)
8+
*/
9+
public class Kasuj extends Actor
10+
{
11+
/**
12+
* Act - do whatever the Kasuj wants to do. This method is called whenever
13+
* the 'Act' or 'Run' button gets pressed in the environment.
14+
*/
15+
public void act()
16+
{
17+
Space swiat=(Space) getWorld();//wywołanie świata
18+
Kasuj guzikKasuj=swiat.buttonKasuj;
19+
if(Greenfoot.mouseClicked(guzikKasuj))
20+
{
21+
swiat.licznik.kasuj();
22+
}
23+
}
24+
}

Minus.class

303 Bytes
Binary file not shown.

Minus.ctxt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=Minus()
4+
numComments=1

Minus.java

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import greenfoot.*;
2+
3+
/**
4+
* Write a description of class Minus here.
5+
*
6+
* @author (your name)
7+
* @version (a version number or a date)
8+
*/
9+
public class Minus extends Dzialanie
10+
{
11+
public Minus(){
12+
wynik = 2;
13+
operator='-';
14+
}
15+
}

Osiem.class

274 Bytes
Binary file not shown.

Osiem.ctxt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=Osiem()
4+
comment0.text=\r\n\ Act\ -\ do\ whatever\ the\ Osiem\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
5+
numComments=1

Osiem.java

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import greenfoot.*;
2+
3+
/**
4+
* Write a description of class Osiem here.
5+
*
6+
* @author (your name)
7+
* @version (a version number or a date)
8+
*/
9+
public class Osiem extends Cyfra
10+
{
11+
/**
12+
* Act - do whatever the Osiem wants to do. This method is called whenever
13+
* the 'Act' or 'Run' button gets pressed in the environment.
14+
*/
15+
public Osiem()
16+
{
17+
cyfraKliknieta = 8;
18+
}
19+
}

Piec.class

270 Bytes
Binary file not shown.

Piec.ctxt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=Piec()
4+
numComments=1

Piec.java

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import greenfoot.*;
2+
3+
/**
4+
* Write a description of class Piec here.
5+
*
6+
* @author (your name)
7+
* @version (a version number or a date)
8+
*/
9+
public class Piec extends Cyfra
10+
{
11+
public Piec(){
12+
cyfraKliknieta=5;
13+
}
14+
}

Plus.class

300 Bytes
Binary file not shown.

Plus.ctxt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=Plus()
4+
numComments=1

Plus.java

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import greenfoot.*;
2+
3+
public class Plus extends Dzialanie
4+
{
5+
public Plus(){
6+
wynik = 1;
7+
operator='+';
8+
}
9+
}

Podziel.class

309 Bytes
Binary file not shown.

Podziel.ctxt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=Podziel()
4+
numComments=1

0 commit comments

Comments
 (0)