Created
March 12, 2020 06:54
-
-
Save emirozturk/ec4e28d4491caec0c3da19ec935ac9d7 to your computer and use it in GitHub Desktop.
NYP 4.Hafta Uygulama
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.emirozturk; | |
import java.io.IOException; | |
import java.nio.charset.StandardCharsets; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.ArrayList; | |
import java.util.List; | |
class Ogrenci{ | |
private int numara; | |
private String ad; | |
Ogrenci(int numara,String ad){ | |
this.numara = numara; | |
this.ad = ad; | |
} | |
boolean esitMi(Ogrenci o){ | |
return o.numara == numara && o.ad.equals(ad); | |
} | |
} | |
class OgrenciIslemleri{ | |
boolean ogrenciKarsilastir(Ogrenci o1,Ogrenci o2){ | |
return o1.esitMi(o2); | |
} | |
Ogrenci ogrenciOku(String kayit){ | |
return new Ogrenci(Integer.parseInt(kayit.split("-")[0]),kayit.split("-")[1]); | |
} | |
boolean listedeVarMi(List<Ogrenci> liste,Ogrenci o){ | |
for(var eleman: liste) | |
if(eleman.esitMi(o)) | |
return true; | |
return false; | |
} | |
} | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
OgrenciIslemleri oi = new OgrenciIslemleri(); | |
List<Ogrenci> ogrenciListesi = new ArrayList<Ogrenci>(); | |
List<String> lines = Files.readAllLines(Paths.get("/Users/emirozturk/Desktop/ogrenciler.txt"), StandardCharsets.UTF_8); | |
for(var line : lines){ | |
ogrenciListesi.add(oi.ogrenciOku(line)); | |
} | |
Ogrenci o = new Ogrenci(1,"a"); | |
System.out.println(oi.listedeVarMi(ogrenciListesi,o)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment