Hirdetés
- Sok pénz mellett az NVLink Fusiont is felkarolja a Marvell
- Mit rejt a telefonod? – A tranzisztorok elképesztő világa
- Fogyókúrával kínálnak több tányért a Toshiba új merevlemezei
- Kicsit visszafogottabban nyávog az Intel Wildcat Lake
- Gyorsabb processzort igen, memóriát alig kapott a Xiaomi új HD tévéokosítója
Új hozzászólás Aktív témák
-
Dirty_Pio
csendes tag
Sziasztok,
Van egy kis problemam a kovetkezo koddal: a foridto leforditja, de amikro futtatom a programot a mainbe arthimetic exeption errort ad es kapa.
class Owner{
private String name;
private int CNP;
private Property[] pr=new Property[16];
private int leng;
public Owner(String name){
this.name=name;
}
public Owner(String name, int CNP)
{
this(name);
this.CNP=CNP;
}
public void buy(Property p[],int len)
{
int i;
for (i=0;i<len;i++)
pr[i]=p[i];
leng=len;
}
public boolean na(String n)
{
if (n==name) return true;
else return false;
}
public boolean cn(int c)
{
if (c==CNP) return true;
else return false;
}
public String toString()
{
String s;
int money=0,i;
s="Owner "+name +"\nProperty:\n";
for (i=0;i<leng;i++)
{
if (pr[i] instanceof Field)
s+="Field:\n"+pr[i].ret();
else
s+="Building:\n"+pr[i].ret();
money+=pr[i].price();
}
s+="\nTotal sum: "+money;
return s;
}
}
abstract class Property{
protected String add;
protected int sur;
public Property(String ad,int s)
{
add=ad;
sur=s;
}
abstract int price();
public String qq()
{
return add+"\nSurface: "+sur+"\n";
}
abstract String ret();
}
class Field extends Property{
private int rank;
public Field (String ad, int s, int r)
{
super(ad,s);
rank=r;
}
public int price ()
{
return 350*sur/rank;
}
public String ret()
{
String s;
s=super.qq();
s+="cost : "+this.price();
return s;
}
}
class Building extends Property{
protected int value;
public Building(String ad,int s)
{
super(ad,s);
}
public int price()
{
return sur*500;
}
public String ret()
{
String s;
s=super.qq();
s+="cost : "+this.price();
return s;
}
}
class Operator{
private String n;
private int nr;
public Operator(String n)
{
this.n=n;
}
public Operator(int nr)
{
this.nr=nr;
}
public int search(Owner[] p,int l)
{
int i;
if (nr==0)
for(i=0;i<l;i++)
{
if (p[i].na(n)) return i;
}
else
for (i=0;i<l;i++)
if (p[i].cn(nr)) return i;
return -1;
}
}
class P5{
public static void main(String [] args)
{
Property[] P;
int i,len=3;
P=new Property[len];
for (i=0;i<len;i++)
{
if (i%2==0) P[i]=new Field("address "+i,i*25,i);
else P[i]=new Building("address "+i,i*75);
}
Owner[] o;
o=new Owner[2];
o[0]=new Owner ("Ion Popescu",225533);
o[1]=new Owner("Gigi",553694);
o[0].buy(P,len);
int q;
Operator op;
op=new Operator("Ion Popescu");
q=op.search(o,2);
if (q!=-1)
System.out.println(o[q]);
}
}
Új hozzászólás Aktív témák
A topicot kiemeltem. Valaki nem akar egy nyitó hsz-t írni?:))
- Eladó G pro superlight 2 se Unusual way sports UHWM skate talpakkal.
- Fehér konfig - i7-4790k/ROG Strix GTX 1070/Wifi/Rengeteg új-dobozos alkatrész/AJÁNDÉK Resident Evil
- 3D 4K Oled Dolby Vision (LGOLED C6EP/LGOLED E6P/LG OLEDG6P)
- 3D 4K Oled Dolby Vision (LGOLED C6EP/LGOLED E6P/LG OLEDG6P)
- HP 150W töltők (19.5V x 7.7A) kis kék, kerek, 4.5 x 3.0 mm
- Apple iPhone 17 Pro Cosmic Orange 256GB karcmentes 100% akku (49 ciklus) garancia 2026.12.29-ig
- billentyűzetek - kiárusítás - Logitech, Corsair, ASUS
- 266 - Lenovo ThinkBook 16 (G6 ABP) - AMD Ryzen 5 7430U, no GPU
- AKCIÓ! Gigabyte B650M R7 8700F 64GB DDR5 1TB SSD RX 7800 XT 16GB LianLi VectorV100R RGB TG 750W
- Kihagyhatatlan áron DELL XPS 13 9310 /i5-1135G7/8 GB Ram/512 GB SSD/FHD+ IPS
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest

