- Autós kamerák
- Gaming notebook topik
- Azonnali fotós kérdések órája
- Októberben kerülnek legacy státuszba a régebbi GeForce VGA-k
- AMD K6-III, és minden ami RETRO - Oldschool tuning
- TCL LCD és LED TV-k
- NVIDIA GeForce RTX 4080 /4080S / 4090 (AD103 / 102)
- Melyik tápegységet vegyem?
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- OLED TV topic
Hirdetés
Köszönjük a sok biztatást, támogatást! Utolsó pillanat a féláras hirdetésfeladásra, előfizetésre!
Ú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?:))
- exHWSW - Értünk mindenhez IS
- Mobil flotta- ajánló keresés belépéshez
- Sütés, főzés és konyhai praktikák
- Bundle topik
- Formula-1
- Autós kamerák
- Gaming notebook topik
- Azonnali fotós kérdések órája
- Októberben kerülnek legacy státuszba a régebbi GeForce VGA-k
- Azonnali mobilos kérdések órája
- További aktív témák...
- Samsung Galaxy A52s 5G 128GB 6GB RAM Dual (A528) Mobiltelefon
- Ohh Lenovo ThinkPad P15 G2 Tervező Vágó Laptop -75% 15,6" i5-11500H 32/1TB RTX A2000 4GB /1 Millió/
- Uhh Lenovo ThinkPad P15 G2 Tervező Vágó Laptop -75% 15,6" i5-11500H 16/1TB RTX A2000 4GB /1 Millió/
- Call of Duty WW2 PS4 játék
- Eladó Konfig I5-10400F 32GB DDR4 256GB SSD 1TB HDD RX6600 8GB!
- Eredeti Lenovo 300W töltők - ADL300SDC3A
- AKCIÓ! ASUS PRO WS W790E-SAGE SE alaplap garanciával hibátlan működéssel
- Samsung Galaxy Watch 7 44mm Bluetooth / 1 hónap garancia / zöld / szép állapot
- Bomba ár! HP EliteBook 845 G9 - Ryzen 5 6650U I 16GB I 512SSD I 14,1" Touch I Cam I W11 I NBD Gari!
- DELL Universal Dock D6000 docking station (452-BCYH) (DisplayLink)
Állásajánlatok
Cég: FOTC
Város: Budapest