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 MOTO;
- import java.util.*;
- public class MOTO {
- String type;
- String color;
- int price;
- public static Comparator obj = new Comparator(){
- @Override
- public int compare(Object t, Object t1) {
- MOTO m1 = (MOTO) t;
- MOTO m2 = (MOTO) t;
- int p = m1.price - m2.price;
- if (p>0) return 1;
- if (p==0) return m1.type.compareToIgnoreCase(m2.type);
- return -1;
- }
- };
- public MOTO(String type, String color, int price) {
- this.type = type;
- this.color = color;
- this.price = price;
- }
- MOTO() {
- }
- @Override
- public String toString() {
- return type +" "+ color +" "+ price ;
- }
- String getprice(){
- if(type.charAt(type.length()-1)=='N')
- return (price+"VND");
- return price+"USD";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement