Hirdetés
- Samsung Galaxy Z Fold7 - ezt vártuk, de…
- iPhone topik
- Milyen okostelefont vegyek?
- Mobil flották
- Samsung Galaxy Watch8 - Classic - Ultra 2025
- Megtartotta Európában a 7500 mAh-t az Oppo
- Xiaomi 15T Pro - a téma nincs lezárva
- Huawei Watch GT 6 és GT 6 Pro duplateszt
- Örömhír: nem spórol Európán a OnePlus
- Azonnali mobilos kérdések órája
Ú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?:))
- Mibe tegyem a megtakarításaimat?
- MILC felhasználók szakmai topikja
- Samsung Galaxy Z Fold7 - ezt vártuk, de…
- Bambu Lab 3D nyomtatók
- Soundbar, soundplate, hangprojektor
- iPhone topik
- Kuponkunyeráló
- Telekom otthoni szolgáltatások (TV, internet, telefon)
- BestBuy topik
- Háztartási gépek
- További aktív témák...
- Dell Precision 7670 4K+ OLED Touch / i9-12950HX 16C / 32GB D5 / 1TB G4 / A2000 8GB / IR / HU tervező
- Z790 Strix-A, 14700K, 2x16GB 7200 mhz, Tuf 4080, Corsair H1000i
- -ÚJ,2 ÉV GAR- GAMER PC: RYZEN 7 5700/5800X +RX 6600/6700XT +16-64GB DDR4! SZÁMLA! 70 féle ház!
- Üzletből, garanciával, DeLL Inspiron 16 5630 -i5-1340P-16 szál/16RAM/512SSD/16,1"FULLHD IPS
- -ÚJ,2 ÉV GAR- GAMER PC: i5-14400F (10mag/16szál) +RX 6600/6700XT +16-64GB DDR4! SZÁMLA! 70 féle ház!
- Lenovo ThinkPad P15 Gen 2 Mobile Workstation - i7-11850H 32GB 512GB Nvidia RTX A4000 8GB 1 év gar.
- GYÖNYÖRŰ iPhone 14 128GB Red -1 ÉV GARANCIA -Kártyafüggetlen, MS3678, 100% Akkumulátor
- Új és használt laptopok , üzletitől a gamerig , kedvező áron. Garanciával !
- ÁRGARANCIA!Épített KomPhone Ryzen 7 7800X3D 32/64GB RAM RX 9070 16GB GAMER PC termékbeszámítással
- Samsung Galaxy Tab A8 32GB, Újszerű, 1 Év Garanciával
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest


