Hirdetés
- VHS digitalizálás
- gban: Ingyen kellene, de tegnapra
- Sub-ZeRo: Euro Truck Simulator 2 & American Truck Simulator 1 (esetleg 2 majd, ha lesz) :)
- GoodSpeed: Nem vénnek való vidék - Berettyóújfalu
- sh4d0w: StarWars: Felismerés
- Luck Dragon: Asszociációs játék. :)
- GoodSpeed: 3I/Atlas: Üstökös vagy idegen civilizáció űrhajója?
- sziku69: Szólánc.
- Luck Dragon: MárkaLánc
- Brogyi: CTEK akkumulátor töltő és másolatai
Ú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
A topicot kiemeltem. Valaki nem akar egy nyitó hsz-t írni?:))
- Szigorúan titkos dokumentumokkal a kezében távozott az Intel egyik mérnöke
- Kínai és egyéb olcsó órák topikja
- Autós topik
- Milyen asztali (teljes vagy fél-) gépet vegyek?
- Hobby elektronika
- Fordulat: időben startol S26+, nézd meg, milyen lesz!
- Fejhallgatós találkozó
- Gitáros topic
- exHWSW - Értünk mindenhez IS
- Google Chromecast topic
- További aktív témák...
- Asztali PC , i5 12400F , RTX 3070 Ti , 32GB RAM , 512GB NVME , 1TB HDD
- Microsoft Surface Go 2 m3-8100Y 8GB 128GB 1 év garancia
- -ÚJ,2 ÉV GAR- GAMER PC: i5-14400F (10mag/16szál) +RX 6600/6700XT +16-64GB DDR4! SZÁMLA! 70 féle ház!
- Microsoft Surface Go 2 m3-8100Y 8GB 128GB 4G LTE 1 év garancia
- APPLE IPAD 10.GEN 64GB Wifi , Pink szinben, Üzletből, 27% ÁFÁS
Állásajánlatok
Cég: NetGo.hu Kft.
Város: Gödöllő
Cég: Laptopműhely Bt.
Város: Budapest


