giorgos8985
Νεοφερμένος
Ο giorgos8985 αυτή τη στιγμή δεν είναι συνδεδεμένος. Είναι 38 ετών. Έχει γράψει 5 μηνύματα.
10-04-08
13:36
Αν θες να φτιαξεις ενα game μπορω να σου δωσω ενα προγραμα που εχω φταξει μονος μου.Ειναι σε γλωσα java και εισαγει δυο παιχτες οποιος εχει την μεγαλυτερη
δυναμη χτυπηματος κερδιζει.Για να λειτουργησει αυτο το προγραμα χρειαζεται και την κλαση του που θα στην δωσω και αυτη.
--merged--
--merged--
δυναμη χτυπηματος κερδιζει.Για να λειτουργησει αυτο το προγραμα χρειαζεται και την κλαση του που θα στην δωσω και αυτη.
--merged--
Code:
[FONT=Courier New][COLOR=#941edf]//Αυτο ειναι το προγραμα
public[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]class[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] GameProg1 {
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]public[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]static[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]void[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] main (String args []) {
Player p1=[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]new[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] Player();
p1.setName([/COLOR][/FONT][FONT=Courier New][COLOR=#00cb00]"Superman"[/COLOR][/FONT][FONT=Courier New][COLOR=#000000]);
p1.setRace([/COLOR][/FONT][FONT=Courier New][COLOR=#00cb00]"superhero"[/COLOR][/FONT][FONT=Courier New][COLOR=#000000]);
p1.setStrength(1000);
p1.setHitPoints(5000);
Player p2=[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]new[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] Player();
p2.setName([/COLOR][/FONT][FONT=Courier New][COLOR=#00cb00]"John Smith"[/COLOR][/FONT][FONT=Courier New][COLOR=#000000]);
p2.setRace([/COLOR][/FONT][FONT=Courier New][COLOR=#00cb00]"human"[/COLOR][/FONT][FONT=Courier New][COLOR=#000000]);
p2.setStrength(20);
p2.setHitPoints(100);
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]if[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] (p1.getStrength()>p2.getStrength()) {
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]int[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] diafora=p1.getStrength()-p2.getStrength();
p2.setHitPoints(p2.getHitPoints()-diafora);
System.out.printf([/COLOR][/FONT][FONT=Courier New][COLOR=#00cb00]"O %s einai o nikitis kai o %s einai "[/COLOR][/FONT][FONT=Courier New][COLOR=#000000],p1.getName(),p2.getName());
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]if[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] (p2.getHitPoints()>0){
System.out.println([/COLOR][/FONT][FONT=Courier New][COLOR=#00cb00]"zontanos"[/COLOR][/FONT][FONT=Courier New][COLOR=#000000]);}
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]else[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] {
System.out.println([/COLOR][/FONT][FONT=Courier New][COLOR=#00cb00]"nekros"[/COLOR][/FONT][FONT=Courier New][COLOR=#000000]);}
}
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]else[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]if[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] (p1.getStrength()<p2.getStrength()) {
System.out.printf([/COLOR][/FONT][FONT=Courier New][COLOR=#00cb00]"O %s einai nikitis kai o %s einai"[/COLOR][/FONT][FONT=Courier New][COLOR=#000000],p2.getName(),p1.getName());
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]if[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] (p1.getHitPoints()>0)
System.out.println([/COLOR][/FONT][FONT=Courier New][COLOR=#00cb00]"zontanos"[/COLOR][/FONT][FONT=Courier New][COLOR=#000000]);
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]else[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] {
System.out.println([/COLOR][/FONT][FONT=Courier New][COLOR=#00cb00]"nekros"[/COLOR][/FONT][FONT=Courier New][COLOR=#000000]);}
}
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]else[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] {
System.out.print([/COLOR][/FONT][FONT=Courier New][COLOR=#00cb00]"O agonas elixe isopalos"[/COLOR][/FONT][FONT=Courier New][COLOR=#000000]);}
}[/COLOR][/FONT]
Code:
[FONT=Courier New][COLOR=#941edf]//Αυτη ειναι η κλαση
public[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]class[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] Player {
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]private[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] String name;
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]private[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] String race;
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]private[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]int[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] strength;
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]private[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]int[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] hitPoints;
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]public[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]void[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] setName(String text) {
name = text;
}
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]public[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]void[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] setRace(String text) {
race = text;
}
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]public[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]void[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] setStrength([/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]int[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] x) {
strength = x;
}
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]public[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]void[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] setHitPoints([/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]int[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] y) {
hitPoints = y;
}
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]public[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] String getName() {
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]return[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] name;
}
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]public[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] String getRace() {
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]return[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] race;
}
[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]public[/COLOR][/FONT][FONT=Courier New][COLOR=#941edf]int[/COLOR][/FONT][FONT=Courier New][COLOR=#000000] getStrength() {}[/COLOR][/FONT]
Σημείωση: Το μήνυμα αυτό γράφτηκε 16 χρόνια πριν. Ο συντάκτης του πιθανόν να έχει αλλάξει απόψεις έκτοτε.