- TCL LCD és LED TV-k
- Milyen egeret válasszak?
- SSD kibeszélő
- OLED TV topic
- Milyen cserélhető objektíves gépet?
- AMD K6-III, és minden ami RETRO - Oldschool tuning
- AMD Navi Radeon™ RX 9xxx sorozat
- Bluetooth hangszórók
- A partnerektől függ, hogy lesz-e Arc csúcs-VGA az aktuális generációban
- Milyen belső merevlemezt vegyek?
Ú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?:))
- iPhone 12 64GB - fehér Garanciális 2026.01.07
- szinte új HP E24m G4 full HD 1920x1080 IPS monitor- rejtett Webkamera - nagy hangszóró - USB-C
- NEC MultiSync EA275WMi 27" képátló/ AH-IPS panel/2560x1440 (WQHD)/ A- kategória nagyon apró hibával!
- új aktiválatlan iPhone 16 128GB black fekete független 1 év Apple garancia
- szinte új iPhone 16 Pro 256GB black titanium fekete titán független Apple 3 év garancia adapter
- Eladó karcmentes állapotban levő Apple iPhone 14 Plus 256GB / AKKU 100% / 12 hónap jótállás
- BESZÁMÍTÁS! 32GB ADATA XPG Lancer RGB 7200MHz DDR5 garanciával hibátlan működéssel
- AKCIÓ! AMD Ryzen 7 3800X 8mag 16szál processzor garanciával hibátlan működéssel
- Bomba ár! HP Elitebook 8560W - i7-2GEN I 8GB I 500GB I 15,6" FHD I Nvidia I W10 I Garancia
- 100 - Lenovo Yoga Pro 9 (16IRP8) - Intel Core i9-13905H, RTX 4070 (ELKELT)
Állásajánlatok
Cég: Promenade Publishing House Kft.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest