- iPhone topik
- One mobilszolgáltatások
- Motorola Edge 50 Neo - az egyensúly gyengesége
- Ilyen lesz a Fairphone 6
- Apple iPhone 16 Pro - rutinvizsga
- Samsung Galaxy S23 Ultra - non plus ultra
- Samsung Galaxy A54 - türelemjáték
- Milyen okostelefont vegyek?
- Középkategóriást mutatott be újra az Oppo
- VoLTE/VoWiFi
Új hozzászólás Aktív témák
-
Dirty_Pio
csendes tag
Sziasztok, mostanaba kezdtem bajlodni a csomagokkal. Inkabb beteszem akodot, hogy lassatok ti is:
//Figure.java:
package Figure;
import java.util.*;
public class Figure
{
protected int ox, oy;
Figure(int x, int y)
{
ox=x;
oy=y;
}
}
// ez utan kovetkeznek a kivetelek, amikre majd szuksegem lesz.
// Rect.java:
package Figure;
public class Rect extends Figure
{
protected int px,py;
Rect(int px, int py, int x, int y)
{
super(x,y);
this.px=px;
this.py=py;
}
public boolean equals(Object o)
{
return (o instanceof Rect)&&((((Rect)o).ox)==this.ox)&&((((Rect)o).oy)==this.oy)&&(((Rect)o).px==this.px)&&(((Rect)o).py==this.py);
}
public String toString()
{
return "Rectangle: "+"xo:"+ox+" oy:"+oy+" side:"+Math.sqrt((px-ox)*(px-ox)+(py-oy)*(py-oy));
}
}
//Circle.java:
package Figure;
public class Circle extends Figure
{
protected int rad;
Circle(int r,int x,int y)
{
super(x,y);
this.rad=r;
}
public boolean equals(Object o)
{
return (o instanceof Circle)&&((((Circle)o).rad==this.rad)&&(((Circle)o).ox==this.ox)&&(((Circle)o).oy==this.oy));
}
public String toString()
{
return "Circle: x="+this.ox+" y="+this.oy+" with radius="+rad;
}
}
//client.java:
package client;
import Figure.*;
public class client{
public static void main(String[] args)
{
Figure z;
Circle c,c2;
Rect p;
p=new Rect(2,3,5,6);
c=new Circle(1,2,16);
try{
Client a=new Client(5);
a.addTo(p);
a.addTo(c);
a.ret();
System.out.println(a.print());
}
catch (notVerify e){
System.out.println(" "+e.getMessage()+" \n");
}
catch (Same e){
System.out.println(" "+e.getMessage()+" \n");
}
catch (Full e)
{
System.out.println(" "+e.getMessage()+" \n");
}
catch (Empty e)
{
System.out.println(" "+e.getMessage()+" \n");
}
c2=new Circle(1,2,16);
}
}
}A Figure packaget szepen le is forditja a program, de amikro a cleintre raterek, akkor azt mondja, hogy nem publikus a Circle meg a Rect osztalyok. Nincs semmi 5letem, hogy mi lehet a gond.
-
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
Hirdetés
A topicot kiemeltem. Valaki nem akar egy nyitó hsz-t írni?:))
- Precision 3480 27% 14" FHD IPS i7-1370P 32GB 512GB NVMe magyar vbill IR kam gar
- Apple watch Ultra 2 megkímélt akku 100% 2025.08.25.Apple jótállás beszámítok!
- Precision 3580 27% 15.6" FHD IPS i7-1360P RTX A500 32GB 512GB NVMe magyar vbill gar
- Intel Core i5-13500 OEM
- Toshiba Surveillance Pro S300 8TB megfigyelőrendszerekre optimalizált merevlemez
- ÁRGARANCIA!Épített KomPhone Ryzen 5 5600X 16/32/64GB RAM RTX 4060 8GB GAMER PC termékbeszámítással
- Bomba ár! Dell Latitude 5400 - i5-8GEN I 16GB I 512SSD I 14" HD I HDMI I Cam I W11 I Gari!
- BESZÁMÍTÁS! Gigabyte A620M R5 7500F 32GB DDR5 512GB SSD RX 6700 XT 12GB ZALMAN S3 TG CM 700W
- Asus ROG G20AJ - Intel Core i7-4790, GTX 980
- BESZÁMÍTÁS! Intel Core i7 8700K 6 mag 12 szál processzor garanciával hibátlan működéssel
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft
Város: Budapest
Cég: Promenade Publishing House Kft.
Város: Budapest