Hirdetés
- HiFi műszaki szemmel - sztereó hangrendszerek
- VR topik
- Internet Rádió építése (hardver), és programozása
- OLED TV topic
- Projektor topic
- Kormányok / autós szimulátorok topikja
- Nem elég a RAM-ok, NAND-ok és VGA-k áremelkedése
- Milyen TV-t vegyek?
- 30 TB fölé ugrott a Seagate HAMR merevlemezcsaládja
- ASUS notebook topic
Új hozzászólás Aktív témák
-
Davs
tag
PetCreator:
//: typeinfo/pets/PetCreator.java
// Creates random sequences of Pets.
package typeinfo.pets;
406
Thinking in Java
Bruce Eckel
import java.util.*;
public abstract class PetCreator {
private Random rand = new Random(47);
// The List of the different types of Pet to create:
public abstract List<Class<? extends Pet>> types();
public Pet randomPet() { // Create one random Pet
int n = rand.nextInt(types().size());
try {
return types().get(n).newInstance();
} catch(InstantiationException e) {
throw new RuntimeException(e);
} catch(IllegalAccessException e) {
throw new RuntimeException(e);
}
}
public Pet[] createArray(int size) {
Pet[] result = new Pet[size];
for(int i = 0; i < size; i++)
result[i] = randomPet();
return result;
}
public ArrayList<Pet> arrayList(int size) {
ArrayList<Pet> result = new ArrayList<Pet>();
Collections.addAll(result, createArray(size));
return result;
}
} ///:~ForNameCreator:
//: typeinfo/pets/ForNameCreator.java
package typeinfo.pets;
import java.util.*;
public class ForNameCreator extends PetCreator {
private static List<Class<? extends Pet>> types =
new ArrayList<Class<? extends Pet>>();
// Types that you want to be randomly created:
private static String[] typeNames = {
"typeinfo.pets.Mutt",
"typeinfo.pets.Pug",
"typeinfo.pets.EgyptianMau",
"typeinfo.pets.Manx",
"typeinfo.pets.Cymric",
Type Information
407
"typeinfo.pets.Rat",
"typeinfo.pets.Mouse",
"typeinfo.pets.Hamster"
};
@SuppressWarnings("unchecked")
private static void loader() {
try {
for(String name : typeNames)
types.add(
(Class<? extends Pet>)Class.forName(name));
} catch(ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
static { loader(); }
public List<Class<? extends Pet>> types() {return types;}
} ///:~
Új hozzászólás Aktív témák
A topicot kiemeltem. Valaki nem akar egy nyitó hsz-t írni?:))
- HiFi műszaki szemmel - sztereó hangrendszerek
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- Azonnali fáradt gőzös kérdések órája
- WoW avagy World of Warcraft -=MMORPG=-
- VR topik
- Internet Rádió építése (hardver), és programozása
- Gyúrósok ide!
- Hardcore café
- eldiablo: 30 év után szakítottunk, de azért még beszélünk...
- Elektromos autók - motorok
- További aktív témák...
- Eladó Konfig I5 7400 16GB DDR4 240GB SSD 512GB HDD GTX1660TI 6GB!
- ÚJ Glorious PC Gaming Race Model WIred O illetve I Bolti ár:14k INGYEN FOXPOST
- ÚJ Glorious PC Gaming Race Model I 2 Wireless Bolti ár:40k INGYEN FOXPOST
- ÚJ Glorious PC Gaming Race Model D/D- USB Bolti ár:10k INGYEN FOXPOST
- ÚJ Glorious Model O 2 Wireless Bolti ár:40k INGYEN FOXPOST
- GYÖNYÖRŰ iPhone XR 64GB Black -1 ÉV GARANCIA - Kártyafüggetlen, MS4270, 100% Akkumulátor
- iMac 16,2 i5-5675R 8GB RAM 1TB SSD NEM FUSION DRIVE!!!
- Nokia 8 Sirocco / 6/128GB / Kártyafüggetlen / 12Hó Garancia
- Dell D6000 univerzális dokkoló USB-C/ USB-A, DisplayLink & Dell WD15 (K17A) USB-C + 130-180W töltő
- Samsung 860 Pro 256GB V-NAND SSD
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest


