You are on page 1of 7

...indowsFormsApplication3\WindowsFormsApplication3\Form1.

cs 1
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Threading.Tasks;
9 using System.Windows.Forms;
10
11 namespace WindowsFormsApplication3
12 {
13 public partial class Form1 : Form
14 {
15 class Tablet
16 {
17
18 private string marka;
19 private string procesor;
20 private string dijagonala;
21 private string memorija;
22 private double cena;
23
24 public Tablet()
25 {
26 marka = " ";
27 procesor = " ";
28 dijagonala = " ";
29 memorija = " ";
30 cena = 0.0f;
31 }
32
33 public Tablet(string m, string p, string d, string mem, double c)
34 {
35 marka = m;
36 procesor = p;
37 dijagonala = d;
38 memorija = mem;
39 cena = c;
40
41 }
42
43 public string GetSetMarka
44 {
45 get { return marka; }
46 set { marka = value; }
47 }
48
49 public string GetSetProcesor
...indowsFormsApplication3\WindowsFormsApplication3\Form1.cs 2
50 {
51 get { return procesor; }
52 set { procesor = value; }
53 }
54
55 public string GetSetDijagonala
56 {
57 get { return dijagonala; }
58 set { dijagonala = value; }
59 }
60
61 public string GetSetMemorija
62 {
63 get { return memorija; }
64 set { memorija = value; }
65 }
66
67 public double GetSetCena
68 {
69 get { return cena; }
70 set { cena = value; }
71 }
72
73 public double UkupnaCena()
74 {
75 string s = "SAMSUNG";
76 string a = "ASUS";
77
78 if (procesor == "AMR Dual Core")
79 {
80 if (marka == s)
81 {
82 return (cena + 1200) * 1.5;
83 }
84 else
85 {
86 if (marka == a)
87 {
88 return ((cena + 1200) * 1.5);
89 }
90 else
91 {
92
93
94 return ((cena + 1200) * 1.3);
95 }
96 }
97 }
98
...indowsFormsApplication3\WindowsFormsApplication3\Form1.cs 3
99 else
100 {
101 if (procesor == "AMR Quard Core")
102 {
103 if (marka == s)
104 {
105 return ((cena + 1400) * 1.5);
106 }
107 else
108 {
109 if (marka == a)
110 {
111 return ((cena + 1400) * 1.5);
112 }
113 else
114 {
115 return ((cena + 1400) * 1.3);
116 }
117 }
118 }
119 else
120 {
121
122 if (marka == s)
123 {
124 return ((cena + 1600) * 1.5);
125 }
126 else
127 {
128 if (marka == a)
129 {
130 return ((cena + 1600) * 1.5);
131 }
132 else
133 {
134 return ((cena + 1600) * 1.3);
135 }
136 }
137 }
138 }
139 }
140
141
142 }
143
144 public Form1()
145 {
146 InitializeComponent();
147 }
...indowsFormsApplication3\WindowsFormsApplication3\Form1.cs 4
148
149 Tablet[] niz = new Tablet[99];
150 int n = 0;
151
152 private void buttonUpis_Click(object sender, EventArgs e)
153 {
154 string d = "", mem = "";
155
156 if (radioButton7inca.Checked == true)
157 {
158 d = "7 inca";
159 }
160 else
161 {
162 if (radioButton8inca.Checked == true)
163 {
164 d = "8 inca";
165 }
166 else
167 {
168 if (radioButton9inca.Checked == true)
169 {
170 d = "9 inca";
171 }
172 }
173 }
174
175 if (radioButton512MB.Checked == true)
176 {
177 mem = "512 MB";
178 }
179 else
180 {
181 if (radioButton1GB.Checked == true)
182 {
183 mem = "1 GB";
184 }
185 else
186 {
187 if (radioButton1_5GB.Checked == true)
188 {
189 mem = "1,5 GB";
190 }
191 else
192 {
193 if (radioButton2GB.Checked == true)
194 {
195 mem = "2 GB";
196 }
...indowsFormsApplication3\WindowsFormsApplication3\Form1.cs 5
197 }
198 }
199 }
200
201 niz[n] = new Tablet(Convert.ToString
(comboBoxMarka.SelectedItem), Convert.ToString
(comboBoxProcesor.SelectedItem),d,mem, Convert.ToSingle
(textBoxCena.Text));
202
203 n++;
204 textBoxCena.Text = " ";
205
206
207 }
208
209
210 static void sortiranje(Tablet[] niz, int n)
211 {
212 int i,j;
213 Tablet t = new Tablet();
214 for (i = 0; i < n-1; i++)
215 for(j=i+1;j< n;j++)
216 {
217 if (string.Compare(niz[i].GetSetMarka, niz[j].GetSetMarka)
> 0)
218 {
219 t = niz[i];
220 niz[i] = niz[j];
221 niz[j] = t;
222
223 }
224 }
225 }
226
227
228 private void buttonIspisSortiranih_Click( object sender, EventArgs e)
229 {
230 listBoxSortirani.ClearSelected();
231
232 int i;
233
234 sortiranje(niz, n);
235
236 for (i = 0; i < n; i++)
237 {
238 listBoxSortirani.Items.Add( "Marka:"+niz[i].GetSetMarka);
239 listBoxSortirani.Items.Add( "Procesor:"+niz[i].GetSetProcesor);
240 listBoxSortirani.Items.Add( "Dijagonala:"+niz
[i].GetSetDijagonala);
...indowsFormsApplication3\WindowsFormsApplication3\Form1.cs 6
241 listBoxSortirani.Items.Add( "Memorija:"+niz[i].GetSetMemorija);
242 listBoxSortirani.Items.Add( "Cena:"+niz[i].GetSetCena);
243 listBoxSortirani.Items.Add( "Ukupna cena:"+niz[i].UkupnaCena());
244 listBoxSortirani.Items.Add( " ");
245 listBoxSortirani.Items.Add( "_____________________________" );
246
247 }
248 }
249
250
251 static void minAsus(Tablet [] niz, int n, ref int min)
252 {
253 int i;
254 for (i = 0; i < n; i++)
255 {
256 if (niz[i].GetSetMarka == "ASUS")
257 {
258
259 min = i;
260 break ;
261 }
262 }
263
264 }
265
266
267 private void buttonMinAsus_Click(object sender, EventArgs e)
268 {
269 int min = 0,br=0;
270 double mina = 0;
271
272 minAsus(niz, n, ref min);
273
274 mina = niz[min].UkupnaCena();
275
276 for (int i = 0; i < n; i++)
277 {
278 if (niz[i].UkupnaCena() < mina && niz[i].GetSetMarka== "ASUS")
279 {
280 br = i;
281 }
282 }
283
284 listBoxASUS.Items.Add( "Marka:" + niz[br].GetSetMarka);
285 listBoxASUS.Items.Add( "Procesor:" + niz[br].GetSetProcesor);
286 listBoxASUS.Items.Add( "Dijagonala:" + niz[br].GetSetDijagonala);
287 listBoxASUS.Items.Add( "Cena:" + niz[br].GetSetCena);
288 listBoxASUS.Items.Add( "Ukupna cena:" + niz[br].UkupnaCena());
289 listBoxASUS.Items.Add( " " );
...indowsFormsApplication3\WindowsFormsApplication3\Form1.cs 7
290
291
292 }
293
294
295 private void button1_Click(object sender, EventArgs e)
296 {
297 int i, br = 0;
298 double sv=0, svr;
299 for (i = 0; i < n; i++)
300 {
301 if (niz[i].GetSetProcesor == "AMR Dual Core")
302 {
303 sv += niz[i].UkupnaCena();
304 br++;
305 }
306 }
307 svr = sv / br;
308
309 textBoxProsek.Text = Convert.ToString(svr);
310 }
311 }
312 }
313

You might also like