- iPhone topik
- Apple Watch
- A hagyományos (nem okos-) telefonok jelene és jövője
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- Fotók, videók mobillal
- Samsung Galaxy Watch (Tizen és Wear OS) ingyenes számlapok, kupon kódok
- Samsung Galaxy S24 Ultra - ha működik, ne változtass!
- Android alkalmazások - szoftver kibeszélő topik
- VoLTE/VoWiFi
- Samsung Galaxy S23 és S23+ - ami belül van, az számít igazán
Új hozzászólás Aktív témák
-
sztikac
őstag
válasz
yossarian14 #11896 üzenetére
Huh, ha hiszed ha nem kb. 25x átfutottam ezt a kódrészletet és az agyam automatikusan így dolgozta fel:
public boolean equals(Person compared) {...}
Köszi!
-
sztikac
őstag
Ha már MOOC... Van ez a kód:
public boolean equals(Object compared) {
// if the variables are located in the same position, they are equal
if (this == compared) {
return true;
}
// if the compared object is not of type Person, the objects are not equal
if (!(compared instanceof Person)) {
return false;
}
// convert the object into a Person object
Person comparedPerson = (Person) compared;
// if the values of the object variables are equal, the objects are equal
if (this.name.equals(comparedPerson.name) &&
this.age == comparedPerson.age &&
this.weight == comparedPerson.weight &&
this.height == comparedPerson.height) {
return true;
}
// otherwise the objects are not equal
return false;
}Itt nem igazán értem, hogy a type cast-ra (
Person comparedPerson = (Person) compared;
) mi szükség van, hiszen a metódus már megkapja a compared objektumot -
sztikac
őstag
-
sztikac
őstag
remélem nagyon kezdő kérdések is elférnek itt
Elkezdtem a MOOC.fi Java programozás kurzust és az egyik feladatnál elakadtam.
Illetve a feladatot magát meg tudtam oldani, az ellenőrzés mégis hibaüzenetet dob rá.
Ez lenne a kód:import java.util.Scanner;
public class InAHoleInTheGround {
public static void main(String[] args) {
printText();
}
public static void printText() {
Scanner scanner = new Scanner(System.in);
System.out.println("Give numbers:");
int sum = 0;
int count = 0;
int even = 0;
int odd = 0;
while (true) {
int number = Integer.valueOf(scanner.nextLine());
if (number == -1) {
break;
}
sum += number;
count++;
if (number % 2 == 0) {
even++;
} else {
odd++;
}
}
System.out.println("Thx! Bye!");
if (count != 0 && sum != 0) {
System.out.println("Sum: " + sum);
System.out.println("Numbers: " + count);
System.out.println("Average: " + 1.0 * sum / count);
System.out.println("Even: " + even);
System.out.println("Odd: " + odd);
}
}
}Tudnátok segíteni, mi lehet a gond?
Új hozzászólás Aktív témák
Hirdetés
A topicot kiemeltem. Valaki nem akar egy nyitó hsz-t írni?:))
- BESZÁMÍTÁS! Asus TUF B450M R5 5600X 32GB DDR4 512GB SSD RTX 3060 XC 12GB Rampage SHIVA Chieftec 600W
- Bomba ár! Toshiba Satellite Pro R50-C - i3-6G I 4GB I 128GB SSD I 15,6" I HDMI I Cam I W10 I Gari!
- LG 27GR93U-B - 27" IPS - UHD 4K - 144Hz 1ms - NVIDIA G-Sync - FreeSync Premium - HDR 400
- AKCIÓ! Gigabyte H510M i5 10400F 16GB DDR4 512GB SSD GTX 1080Ti 11GB Rampage SHIVA Zalman 600W
- Telefon felvásárlás!! Honor 200 Lite, Honor 200, Honor 200 Pro, Honor 200 Smart
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: CAMERA-PRO Hungary Kft
Város: Budapest