Недавно я много читал о разделяемых библиотеках в Linux, и вот что я узнал:
soname
, включая его основной номер версии. Примерно так: libfoo.so.1
libfoo.so.1.0
/ usr / local / lib
, если ldconfig
запущен, он будет читать soname
и создайте символическую ссылку с именем libfoo.so.1
, указывающую на libfoo.so.1.0
. libfoo.so
, указывающую на libfoo.so.1.0
.
int Year
String authorName I must sort the books by one, two or all three of the variables in ascending or descending ... I am stuck in that I have an Object Book that got three variables
String title
int Year
String authorName
I must sort the books by one, two or all three of the variables in ascending or descending order, I implemented the title ordering but I am stuck as to what to do when people choose more than one variable to order.
Here is some of my code:
Book Class:
import java.util.ArrayList;
public class Book{
String title;
String authorName;
int editionYear;
public Book(String title, String authorName, int editionYear){
this.title = title;
this.authorName = authorName;
this.editionYear = editionYear;
}
public String getBookInfo(){
ArrayList bookInfo = new ArrayList();
bookInfo.add(this.title);
bookInfo.add(this.authorName);
bookInfo.add(this.editionYear);
return bookInfo.toString();
}
}
BookSorter Class:
import java.util.Arrays;
import java.util.Comparator;
public class BookSorter{
private String sortkey;
private String order;
Book[] Books;
public BookSorter(Book Book1, Book Book2, Book Book3, Book Book4){
this.Books = new Book[] {Book1, Book2, Book3, Book4};
}
public Book[] sortByTitle(boolean sortorder){
Comparator<Book> byTitle = new TitleComparator(sortorder);
Arrays.sort(Books, byTitle);
for(int i=0;i<4;i++) System.out.println(Books[i].title);
return Books;
}
}
TitleComparator:
import java.util.Comparator;
class TitleComparator implements Comparator<Book> {
boolean ascending;
public TitleComparator(boolean ascending){
this.ascending = ascending;
}
public int compare(Book Book1, Book Book2){
if(ascending == true){
if(Book1.title.compareToIgnoreCase(Book2.title) > 0) return 1;
else if(Book1.title.compareToIgnoreCase(Book2.title) < 0) return -1;
else return 0;
}else{
if(Book2.title.compareToIgnoreCase(Book1.title) < 0) return -1;
else if(Book2.title.compareToIgnoreCase(Book1.title) > 0) return 1;
else return 0;
}
}
}
I though I could work a little more on the comparator but I am really stuck on how to model such a thing, Thanks in advance