Hirdetés
- Xiaomi 15T - reakció nélkül nincs egyensúly
- Samsung Galaxy S25 - végre van kicsi!
- Netfone
- Miért fárad gyorsabban az iPhone akku, mint az androidos?
- „Új mérce az Android világában” – Kezünkben a Vivo X300 és X300 Pro
- Xiaomi 15 Ultra - kamera, telefon
- Kis méret, nagy változás a Motorolánál
- Dupla kamerával menekülne az iPhone Air a kaszától
- Android alkalmazások - szoftver kibeszélő topik
- Samsung Galaxy Z Fold7 - ezt vártuk, de…
Ú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?:))
- Xbox One / Series X Játékok
- Új 2TB 2000GB m.2 Külső SSD, tesztelt, garancia
- ZBook Studio 15 G8 15.6" FHD IPS i7-11850H RTX A2000 32GB 512GB NVMe ujjlolv IR kam gar
- -ÚJ,2 ÉV GAR- DDR5 GAMER PC: RYZEN 5 8400F/9600X +RX 6600/6700XT +16-64GB DDR5! SZÁMLA! 70 féle ház!
- Garanciás - LG C2 55 OLED TV 4K, 120Hz, 2.1 - OLED55C21LA
- HP EliteBook 850 G7 15.6 inch (256GB SSD, i7-10610U, 8GB DDR4) Akció!
- Eladó Oppo A78 5G 4/128GB / 12 hó jótállás
- Ultimate előfizetés akár 4166 Ft/hó áron! Azonnali, automatizált aktiválással, csak Nálam!
- Bomba ár! Dell Latitude E5540 - i3 / i5 I 6-8GB I 320GB I 15,6" HD I HDMI I Cam I W10 I Gari!
- 2025.10.29 - Frissített lista - Lenovo LOQ / LEGION Pro 7 (RTX 5070Ti / 5080 / 4080 / 4090)
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: NetGo.hu Kft.
Város: Gödöllő


