Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package main;
- /**
- *
- * @author 37060
- */
- public class Paskaita implements Comparable<Paskaita> {
- String pavadinimas;
- String kodas;
- int kredituSkaicius;
- String destytojas;
- int semestras;
- public Paskaita(String pavadinimas, String kodas, int kredituSkaicius) {
- this.pavadinimas = pavadinimas;
- this.kodas = kodas;
- this.kredituSkaicius = kredituSkaicius;
- }
- public Paskaita(String kodas,String pavadinimas, int kredituSkaicius,int semestras, String destytojas) {
- this.pavadinimas = pavadinimas;
- this.kodas = kodas;
- this.kredituSkaicius = kredituSkaicius;
- this.destytojas = destytojas;
- this.semestras = semestras;
- }
- @Override
- public String toString() {
- return semestras +" "+kodas.substring(0, 4)+" "+kodas.substring(kodas.length()-5) + " " + pavadinimas.toUpperCase()+ " " + destytojas +"\n";
- }
- public static boolean arRudens(int semestras) {
- if(semestras%2==0){
- return true;
- }
- else{
- return false;
- }
- }
- @Override
- public int compareTo(Paskaita o) {
- if(this.semestras==o.semestras){
- int lt = Double.compare(this.kredituSkaicius, o.kredituSkaicius);
- if(lt!=0){
- return -lt;
- }
- if(this.kredituSkaicius==o.kredituSkaicius)
- {
- int ml = this.pavadinimas.compareTo(o.pavadinimas);
- if(ml!=0){
- return ml;
- }
- }
- }
- return this.semestras-o.semestras;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement