By GokiSoft.com| 23:41 23/11/2020|
Java Basic

Java basic- Assignment - Quản lý xe cộ

* Tạo một giao diện IXe nằm trong gói xeco.info gồm có 2 phương thức:

            - public void nhap();

            - public void hienthi();

 

* Tạo Lớp XeMay cũng nằm trong gói xeco.info thực thi giao diện IXe và có các thuộc tính sau:

            String bienso;

            String loaixe;

            String mauxe;

            float giatien;

Cài đặt Constructor, các phương thức set/get và Override các phương thức trong giao diện IXe.

 

* Tạo lớp XeMayHoaBinh nằm trong gói hoabinh.xemay kế thừa lớp XeMay. Bổ sung thêm thuộc tính:

            - n (kiểu int)    : Dùng để nhập vào số lượng xe

- Một mảng n phần tử kiểu XeMay dùng để lưu thông tin của n xe máy đang quản lý tại tỉnh Hòa Bình.

Cài đặt constructor, override tất cả các phương thức trong lớp XeMay. Phương thức nhập phải nhập vào số lượng xe và gọi nhập thông tin của n xe đó.

 

* Tạo lớp XeMayHaNoi nằm trong gói hanoi.xemay kế thừa lớp XeMay. Bổ sung thêm thuộc tính:

            - n (kiểu int)    : Dùng để nhập vào số lượng xe

- Một mảng n phần tử kiểu XeMay dùng để lưu thông tin của n xe máy đang quản lý tại tỉnh Hà Nội.

Cài đặt constructor, override tất cả các phương thức trong lớp XeMay. Phương thức nhập phải nhập vào số lượng xe và gọi nhập thông tin của n xe đó.

 

* Tạo lớp QuanLyChung nằm trong gói quanlychung.xemay, có menu như sau:

            1. Nhập thông tin cho n xe máy tại tỉnh Hòa Bình.

            2. Nhập thông tin cho n xe máy tại tỉnh Hà Nội.

            3. Sắp xếp danh sách tăng theo biển số xe.

            4. Tìm kiếm thông tin xe theo biển số xe.

            5. Thống kê số lượng xe đang quản lý.

            6. Thoát

 

-          Yêu cầu:

o   Sau khi người sử dụng chọn chức năng 3, 4, 5 sẽ đưa ra thông báo nhập vào tỉnh cần thực hiện (Hòa Bình hoặc Hà Nội).

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Hoang Ngo [T1907A]
Hoang Ngo

2020-04-10 08:06:29



/*
 * 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 xeco.info;

import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class XeMay implements IXe{
    String bienso;
    String loaixe;
    String mauxe;
    float giatien;

    public XeMay() {
    }

    public XeMay(String bienso, String loaixe, String mauxe, float giatien) {
        this.bienso = bienso;
        this.loaixe = loaixe;
        this.mauxe = mauxe;
        this.giatien = giatien;
    }

    public String getBienso() {
        return bienso;
    }

    public void setBienso(String bienso) {
        this.bienso = bienso;
    }

    public String getLoaixe() {
        return loaixe;
    }

    public void setLoaixe(String loaixe) {
        this.loaixe = loaixe;
    }

    public String getMauxe() {
        return mauxe;
    }

    public void setMauxe(String mauxe) {
        this.mauxe = mauxe;
    }

    public float getGiatien() {
        return giatien;
    }
   
    public void setGiatien(float giatien) {
        this.giatien = giatien;
    }
    @Override
    public void input(){
        Scanner scan = new Scanner(System.in);
        System.out.println("Nhap bien so:");
        bienso = scan.nextLine();
        System.out.println("Nhap loai xe:");
        loaixe = scan.nextLine();
        System.out.println("Nhap mau xe:");
        mauxe = scan.nextLine();
        System.out.println("Nhap gia tien:");
        giatien = Float.parseFloat(scan.nextLine());
    }
    @Override
    public void display(){
        System.out.println("Bien so:" + bienso);
        System.out.println("Loai xe:" + loaixe);
        System.out.println("Mau xe:" + mauxe);
        System.out.println("Gia tien:" + giatien);
    }
    
}



/*
 * 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 xeco.info;

/**
 *
 * @author Administrator
 */
public interface IXe {
    
    
    public void input();
    
    
    public void display();
}



/*
 * 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 quanlichung.xemay;

import hanoi.xemay.XeMayHaNoi;
import hoabinh.xemay.XeMayHoaBinh;
import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class QuanLyChung {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int choose,n;
        ArrayList<XeMayHoaBinh> HBList = new ArrayList<>();
        ArrayList<XeMayHaNoi> HNList = new ArrayList<>();
        XeMayHoaBinh xmhb = new XeMayHoaBinh();
        XeMayHaNoi xmhn = new XeMayHaNoi();
        
        do{
            menu();
            choose = Integer.parseInt(scan.nextLine());
            switch(choose){
                case 1:                    
                    xmhb.input();                     
                    break;
                case 2:
                    xmhn.input();                  
                    break;
                case 3:
                    System.out.println("1. Hoa Binh");
                    System.out.println("2. Ha Noi");
                    System.out.println("Choose:");
                    n = Integer.parseInt(scan.nextLine());
                    switch(choose){
                        case 1:
                            xmhb.sort();
                            break;
                        case 2:
                            xmhn.sort();
                            break;
                        default:
                            break;
                    }
                    break;
                case 4:
                    System.out.println("1. Hoa Binh");
                    System.out.println("2. Ha Noi");
                    System.out.println("Choose:");
                    n = Integer.parseInt(scan.nextLine());
                    switch(choose){
                        case 1:
                            xmhb.search();
                            break;
                        case 2:
                            xmhn.search();
                            break;
                        default:
                            break;
                    }
                    break;
                case 5:
                    System.out.println("1. Hoa Binh");
                    System.out.println("2. Ha Noi");
                    System.out.println("Choose:");
                    n = Integer.parseInt(scan.nextLine());
                    switch(choose){
                        case 1:
                            xmhb.thongKeSL();
                            break;
                        case 2:
                            xmhn.thongKeSL();
                            break;
                        default:
                            break;
                    }
                    break;
                case 6:
                    System.out.println("Thoat.");
                    break;
                default:
                    System.out.println("INPUT FAILED !!!");
                    break;
            }
        }while(choose != 6);
        
    }
    
    public static void menu(){
        System.out.println("1. Nhập thông tin cho n xe máy tại tỉnh Hòa Bình.");
        System.out.println("2. Nhập thông tin cho n xe máy tại tỉnh Hà Nội.");
        System.out.println("3. Sắp xếp danh sách tăng theo biển số xe.");
        System.out.println("4. Tìm kiếm thông tin xe theo biển số xe.");
        System.out.println("5. Thống kê số lượng xe đang quản lý.");
        System.out.println(" 6. Thoát");
    }
}
/*
 * 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 hoabinh.xemay;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import java.util.Scanner;
import xeco.info.XeMay;

/**
 *
 * @author Administrator
 */
public class XeMayHoaBinh extends XeMay{
    
    Scanner scan = new Scanner(System.in);
    int n;   
    ArrayList<XeMay> xeMayHBList = new ArrayList<>();

    public XeMayHoaBinh() {
    }

    public XeMayHoaBinh(int n, String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
        this.n = n;
    }
    
    @Override
    public void input(){
        System.out.println("Nhap so luong xe may HB:");
        n = Integer.parseInt(scan.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xemayhb = new XeMay();
            xemayhb.input();
            xeMayHBList.add(xemayhb);
        }
    }
    @Override
    public void display(){
        System.out.println("Danh sach xe may HB");
        for (int i = 0; i < xeMayHBList.size(); i++) {
            xeMayHBList.get(i).display();
        }
    }
    public void sort(){
        Collections.sort(xeMayHBList, new Comparator<XeMay>() {
            @Override
            public int compare(XeMay o1, XeMay o2) {
                if(o1.getBienso().equalsIgnoreCase(o2.getBienso())){
                    return 1;
                }return -1;
            }
        });
        display();
        }
    public void search(){
        System.out.println("Nhap bien so xe can tim:");
        String bienSo = scan.nextLine();
        for (int i = 0; i < xeMayHBList.size(); i++) {
            if(xeMayHBList.get(i).getBienso().equalsIgnoreCase(bienSo)){
                xeMayHBList.get(i).display();
            }
        }
    }
    public void thongKeSL(){
        System.out.println("So luong xe quan ly tai HB :" + xeMayHBList.size());
    }
    
    
}



Hoang Ngo [T1907A]
Hoang Ngo

2020-04-10 08:06:28



/*
 * 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 xeco.info;

import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class XeMay implements IXe{
    String bienso;
    String loaixe;
    String mauxe;
    float giatien;

    public XeMay() {
    }

    public XeMay(String bienso, String loaixe, String mauxe, float giatien) {
        this.bienso = bienso;
        this.loaixe = loaixe;
        this.mauxe = mauxe;
        this.giatien = giatien;
    }

    public String getBienso() {
        return bienso;
    }

    public void setBienso(String bienso) {
        this.bienso = bienso;
    }

    public String getLoaixe() {
        return loaixe;
    }

    public void setLoaixe(String loaixe) {
        this.loaixe = loaixe;
    }

    public String getMauxe() {
        return mauxe;
    }

    public void setMauxe(String mauxe) {
        this.mauxe = mauxe;
    }

    public float getGiatien() {
        return giatien;
    }
   
    public void setGiatien(float giatien) {
        this.giatien = giatien;
    }
    @Override
    public void input(){
        Scanner scan = new Scanner(System.in);
        System.out.println("Nhap bien so:");
        bienso = scan.nextLine();
        System.out.println("Nhap loai xe:");
        loaixe = scan.nextLine();
        System.out.println("Nhap mau xe:");
        mauxe = scan.nextLine();
        System.out.println("Nhap gia tien:");
        giatien = Float.parseFloat(scan.nextLine());
    }
    @Override
    public void display(){
        System.out.println("Bien so:" + bienso);
        System.out.println("Loai xe:" + loaixe);
        System.out.println("Mau xe:" + mauxe);
        System.out.println("Gia tien:" + giatien);
    }
    
}



/*
 * 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 xeco.info;

/**
 *
 * @author Administrator
 */
public interface IXe {
    
    
    public void input();
    
    
    public void display();
}



/*
 * 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 quanlichung.xemay;

import hanoi.xemay.XeMayHaNoi;
import hoabinh.xemay.XeMayHoaBinh;
import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class QuanLyChung {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int choose,n;
        ArrayList<XeMayHoaBinh> HBList = new ArrayList<>();
        ArrayList<XeMayHaNoi> HNList = new ArrayList<>();
        XeMayHoaBinh xmhb = new XeMayHoaBinh();
        XeMayHaNoi xmhn = new XeMayHaNoi();
        
        do{
            menu();
            choose = Integer.parseInt(scan.nextLine());
            switch(choose){
                case 1:                    
                    xmhb.input();                     
                    break;
                case 2:
                    xmhn.input();                  
                    break;
                case 3:
                    System.out.println("1. Hoa Binh");
                    System.out.println("2. Ha Noi");
                    System.out.println("Choose:");
                    n = Integer.parseInt(scan.nextLine());
                    switch(choose){
                        case 1:
                            xmhb.sort();
                            break;
                        case 2:
                            xmhn.sort();
                            break;
                        default:
                            break;
                    }
                    break;
                case 4:
                    System.out.println("1. Hoa Binh");
                    System.out.println("2. Ha Noi");
                    System.out.println("Choose:");
                    n = Integer.parseInt(scan.nextLine());
                    switch(choose){
                        case 1:
                            xmhb.search();
                            break;
                        case 2:
                            xmhn.search();
                            break;
                        default:
                            break;
                    }
                    break;
                case 5:
                    System.out.println("1. Hoa Binh");
                    System.out.println("2. Ha Noi");
                    System.out.println("Choose:");
                    n = Integer.parseInt(scan.nextLine());
                    switch(choose){
                        case 1:
                            xmhb.thongKeSL();
                            break;
                        case 2:
                            xmhn.thongKeSL();
                            break;
                        default:
                            break;
                    }
                    break;
                case 6:
                    System.out.println("Thoat.");
                    break;
                default:
                    System.out.println("INPUT FAILED !!!");
                    break;
            }
        }while(choose != 6);
        
    }
    
    public static void menu(){
        System.out.println("1. Nhập thông tin cho n xe máy tại tỉnh Hòa Bình.");
        System.out.println("2. Nhập thông tin cho n xe máy tại tỉnh Hà Nội.");
        System.out.println("3. Sắp xếp danh sách tăng theo biển số xe.");
        System.out.println("4. Tìm kiếm thông tin xe theo biển số xe.");
        System.out.println("5. Thống kê số lượng xe đang quản lý.");
        System.out.println(" 6. Thoát");
    }
}
/*
 * 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 hoabinh.xemay;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import java.util.Scanner;
import xeco.info.XeMay;

/**
 *
 * @author Administrator
 */
public class XeMayHoaBinh extends XeMay{
    
    Scanner scan = new Scanner(System.in);
    int n;   
    ArrayList<XeMay> xeMayHBList = new ArrayList<>();

    public XeMayHoaBinh() {
    }

    public XeMayHoaBinh(int n, String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
        this.n = n;
    }
    
    @Override
    public void input(){
        System.out.println("Nhap so luong xe may HB:");
        n = Integer.parseInt(scan.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xemayhb = new XeMay();
            xemayhb.input();
            xeMayHBList.add(xemayhb);
        }
    }
    @Override
    public void display(){
        System.out.println("Danh sach xe may HB");
        for (int i = 0; i < xeMayHBList.size(); i++) {
            xeMayHBList.get(i).display();
        }
    }
    public void sort(){
        Collections.sort(xeMayHBList, new Comparator<XeMay>() {
            @Override
            public int compare(XeMay o1, XeMay o2) {
                if(o1.getBienso().equalsIgnoreCase(o2.getBienso())){
                    return 1;
                }return -1;
            }
        });
        display();
        }
    public void search(){
        System.out.println("Nhap bien so xe can tim:");
        String bienSo = scan.nextLine();
        for (int i = 0; i < xeMayHBList.size(); i++) {
            if(xeMayHBList.get(i).getBienso().equalsIgnoreCase(bienSo)){
                xeMayHBList.get(i).display();
            }
        }
    }
    public void thongKeSL(){
        System.out.println("So luong xe quan ly tai HB :" + xeMayHBList.size());
    }
    
    
}



nguyễn văn huy [T1907A]
nguyễn văn huy

2020-03-16 14:52:39



/*
 * 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 quanlixemay;
import java.util.*;
/**
 *
 * @author ASUS
 */
public class xemayhoabinh extends xemay {
    ArrayList<xemay> xemayl=new ArrayList<>();
    int n;

    public xemayhoabinh() {
    }

    public xemayhoabinh(int n, String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
        this.n = n;
    }
      @Override
    public void nhap(){
          System.out.println("nhap so xe hoa binh");
          n=Integer.parseInt(scan.nextLine());
          for (int i = 0; i < n; i++) {
              xemay xemay=new xemay();
              xemay.nhap();
              xemayl.add(xemay);
          }
    }
   
    public void hienthi(){
        System.out.println("danh sach xe may hoa binh");
        for (int i = 0; i < xemayl.size(); i++) {
            xemayl.get(i).display();
        }
    }
    public void timbienso(){
        Collections.sort(xemayl, new Comparator<xemay>() {
            @Override
            public int compare(xemay o1, xemay o2) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }
        });
        hienthi();
    }
    public void tim(){
        float thao=Float.parseFloat(scan.nextLine());
        for (int i = 0; i <xemayl.size(); i++) {
            if(xemayl.get(i).getBienso().equalsIgnoreCase(bienso)){
                xemayl.get(i).display();
            }
        }
    }
     public void tat(){
        System.out.println("so xe hoa binh" +xemayl.size());
    }
}
   .......
/*
 * 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 quanlixemay;
import java.util.*;
/**
 *
 * @author ASUS
 */
public class xemayhanoi extends xemay {
    ArrayList<xemay> xemayl=new ArrayList<>();
    int n;
    Scanner scan=new Scanner(System.in);
    public xemayhanoi() {
    }

    public xemayhanoi(int n, String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
        this.n = n;
    }
    public void nhap(){
          System.out.println("nhap so xe ha noi");
          n=Integer.parseInt(scan.nextLine());
          for (int i = 0; i < n; i++) {
              xemay xemay=new xemay();
              xemay.nhap();
              xemayl.add(xemay);
          }
    }
   
    public void hienthi(){
        System.out.println("danh sach xe may ha noi");
        for (int i = 0; i < xemayl.size(); i++) {
            xemayl.get(i).display();
        }
    }
    public void timbienso(){
        Collections.sort(xemayl, new Comparator<xemay>() {
            @Override
            public int compare(xemay o1, xemay o2) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }
        });
        hienthi();
    }
    public void tim(){
        float thao=Float.parseFloat(scan.nextLine());
        for (int i = 0; i <xemayl.size(); i++) {
            if(xemayl.get(i).getBienso().equalsIgnoreCase(bienso)){
                xemayl.get(i).display();
            }
        }
    }
    public void tat(){
        System.out.println("so xe hoa binh" +xemayl.size());
    }
            
}
......
/*
 * 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 quanlixemay;
import java.util.*;
/**
 *
 * @author ASUS
 */
public class xemay {
     String bienso, loaixe, mauxe;
    float giatien;
    Scanner scan = new Scanner(System.in);

    public xemay() {
    }

    public xemay(String bienso, String loaixe, String mauxe, float giatien) {
        this.bienso = bienso;
        this.loaixe = loaixe;
        this.mauxe = mauxe;
        this.giatien = giatien;
    }
    public void nhap(){
        System.out.println("nhap bien so xe");
        bienso=scan.nextLine();
        System.out.println("nhap loai xe");
        loaixe=scan.nextLine();
        System.out.println("nhap mau xe");
        mauxe=scan.nextLine();
        System.out.println("nhap gia tien");
        giatien=Integer.parseInt(scan.nextLine());
        
    }

    public String getBienso() {
        return bienso;
    }

    public void setBienso(String bienso) {
        this.bienso = bienso;
    }

    public String getLoaixe() {
        return loaixe;
    }

    public void setLoaixe(String loaixe) {
        this.loaixe = loaixe;
    }

    public String getMauxe() {
        return mauxe;
    }

    public void setMauxe(String mauxe) {
        this.mauxe = mauxe;
    }

    public float getGiatien() {
        return giatien;
    }

    public void setGiatien(float giatien) {
        this.giatien = giatien;
    }

    public Scanner getScan() {
        return scan;
    }

    public void setScan(Scanner scan) {
        this.scan = scan;
    }
    
    public void display(){
        System.out.println(toString());
    }

    @Override
    public String toString() {
        return "xemay{" + "bienso=" + bienso + ", loaixe=" + loaixe + ", mauxe=" + mauxe + ", giatien=" + giatien + ", scan=" + scan + '}';
    }

   
    
}
.....
/*
 * 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 quanlixemay;

import java.util.*;

/**
 *
 * @author ASUS
 */
public class quanlichung {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        xemayhoabinh hb = new xemayhoabinh();
        xemayhanoi hn = new xemayhanoi();
        int choise;
        do {
            menu();
            choise = Integer.parseInt(scan.nextLine());
            switch (choise) {
                case 1:
                    hb.nhap();
                    break;
                case 2:
                    hn.nhap();
                    break;
                case 3:
                    System.out.println("1.sap sep bien so xe hoa binh");
                    System.out.println("2.sap sep bien so xe ha noi");
                    System.out.println("chon......");
                    choise=Integer.parseInt(scan.nextLine());
                    switch(choise){
                        case 1:
                            hb.timbienso();
                            break;
                        case 2:
                            hn.timbienso();
                            break;
                        default:
                            break;
                    }
                    break;
                case 4:
                    System.out.println("1.tim bien so xe hoa binh");
                    System.out.println("2.tim bien so xe ha noi");
                    System.out.println("chon......");
                    choise=Integer.parseInt(scan.nextLine());
                    switch(choise){
                        case 1:
                            hb.tim();
                            break;
                        case 2:
                            hn.tim();
                            break;
                        default:
                            break;
                    }
                    break;
                  
                case 5:
                    System.out.println("1.thong ke so xe hoa binh");
                    System.out.println("2.thong ke so xe ha noi");
                    System.out.println("chon......");
                    choise=Integer.parseInt(scan.nextLine());
                    switch(choise){
                        case 1:
                            hb.tat();
                            break;
                        case 2:
                            hn.tat();
                            break;
                        default:
                            break;
                    }
                    break;
                
                case 6:
                    System.out.println("thoat");
                    break;
                default:
                    System.out.println("!!!!!!!");
                    break;
            }
        } while (choise != 6);
    }

    public static void menu() {
        System.out.println(" 1.thong tin xe may hoa binh");
        System.out.println(" 2.nhap thong tin xe may ha noi");
        System.out.println(" 3. Sắp xếp danh sách tăng theo biển số xe.");
        System.out.println(" 4. Tìm kiếm thông tin xe theo biển số xe");
        System.out.println(" 5. Thống kê số lượng xe đang quản lý.");
        System.out.println(" 6.Thoat");
        System.out.println(" 7.choise");
    }
}



NguyenHuuThanh [T1907A]
NguyenHuuThanh

2020-03-15 02:56:55



Quanlychung
/*
 * 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 hanoi.xemay;
import java.util.Scanner;
import java.util.ArrayList;
import Assignment01.XeMay;
import java.util.Collections;
import java.util.Comparator;

/**
 *
 * @author Minh
 */
public class XeMayHaNoi extends XeMay {
    Integer n;
    ArrayList<XeMay> xemayhanoi = new ArrayList<>();
    
    public XeMayHaNoi()
    {
        
    }

    public XeMayHaNoi(Integer n) {
        this.n = n;
    }

    public XeMayHaNoi(Integer n, String bienso, String loaixe, String mauxe, Float giatien) {
        super(bienso, loaixe, mauxe, giatien);
        this.n = n;
    }

    public Integer getN() {
        return n;
    }

    public void setN(Integer n) {
        this.n = n;
    }

    public ArrayList<XeMay> getXemayhanoi() {
        return xemayhanoi;
    }

    public void setXemayhanoi(ArrayList<XeMay> xemayhanoi) {
        this.xemayhanoi = xemayhanoi;
    }
    
    @Override
    public void nhap()
    {
        System.out.println("Nhap vao so luong xe");
        Scanner scan = new Scanner(System.in);
        n = Integer.parseInt(scan.nextLine());
        for ( int i = 0 ; i < n ; i++)
        {
            XeMay xemayhn = new XeMay();
            xemayhn.nhap();
            xemayhanoi.add(xemayhn);
        }
    }
    @Override
    public void hienthi()
    {
        System.out.println("Hien thi danh sach xe");
        for ( int i = 0; i < xemayhanoi.size() ; i++)
        {
            xemayhanoi.get(i).hienthi();
        }
        
    }
  public void sapxep()
    {
        Collections.sort(xemayhanoi, new Comparator<XeMay>(){
            @Override
            public int compare(XeMay o1 , XeMay o2){
                int t1 = Integer.parseInt(o1.getBienso());
                int t2 = Integer.parseInt(o2.getBienso());
                if (t1 > t2)
                {
                    return 1;
                }
                return -1;
            }
        });
        for (int i = 0; i < xemayhanoi.size(); i++)
        {
            xemayhanoi.get(i).hienthi();
        }
        
    }
 
   public void timkiem()
    {
        Scanner scan = new Scanner(System.in);
        System.out.println("nhap thong tin bien so xe");
        String bsx = scan.nextLine();
        for (int i = 0; i < xemayhanoi.size() ; i++)
        {
            if(xemayhanoi.get(i).getBienso().equalsIgnoreCase(bsx)){
                xemayhanoi.get(i).hienthi();
            }
        }
    } 
   public void thongke(){
       System.out.println(xemayhanoi.size());
   }
}

xmhb

/*

 * 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 hoabinh.xemay;

import java.util.Scanner;

import java.util.ArrayList;

import Assignment01.XeMay;

import java.util.Collections;

import java.util.Comparator;


/**

 *

 * @author Minh

 */

public class XeMayHoaBinh extends XeMay {

    Integer n;

    ArrayList<XeMay> xemayhoabinh = new ArrayList<>();


    public XeMayHoaBinh()

    {

        

    }


    public XeMayHoaBinh(Integer n) {

        this.n = n;

    }


    public XeMayHoaBinh(Integer n, String bienso, String loaixe, String mauxe, Float giatien) {

        super(bienso, loaixe, mauxe, giatien);

        this.n = n;

    }


    public Integer getN() {

        return n;

    }


    public void setN(Integer n) {

        this.n = n;

    }


    public ArrayList<XeMay> getXemayhoabinh() {

        return xemayhoabinh;

    }


    public void setXemayhoabinh(ArrayList<XeMay> xemayhoabinh) {

        this.xemayhoabinh = xemayhoabinh;

    }

    @Override

    public void nhap()

    {

        System.out.println("Nhap so luong xe may");

        Scanner scan = new Scanner(System.in);

        n = Integer.parseInt(scan.nextLine());

        for (int i = 0 ; i< n ; i++)

        {

        XeMay xemay = new XeMay();

        xemay.nhap();

        xemayhoabinh.add(xemay);

        

        }

        

    }

    @Override 

    public void hienthi()

    {

        System.out.println("In ra danh sach xe");

        for (  int i = 0 ; i < xemayhoabinh.size() ; i++)

        {

            xemayhoabinh.get(i).hienthi();

        }

     

    }

    public void sapxep()

    {

        Collections.sort(xemayhoabinh, new Comparator<XeMay>(){

            @Override

            public int compare(XeMay o1 , XeMay o2){

                int t1 = Integer.parseInt(o1.getBienso());

                int t2 = Integer.parseInt(o2.getBienso());

                if (t1 > t2)

                {

                    return 1;

                }

                return -1;

            }

        });

        for (int i = 0; i < xemayhoabinh.size(); i++)

        {

            xemayhoabinh.get(i).hienthi();

        }

        

    }

    public void timkiem()

    {

        Scanner scan = new Scanner(System.in);

        System.out.println("nhap thong tin bien so xe");

        String bsx = scan.nextLine();

        for (int i = 0; i < xemayhoabinh.size() ; i++)

        {

            if(xemayhoabinh.get(i).getBienso().equalsIgnoreCase(bsx)){

                xemayhoabinh.get(i).hienthi();

            }

        }

    }

    public void thongke(){

       System.out.println(xemayhoabinh.size());

   }


    

}

 xmhn

/*

 * 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 hanoi.xemay;

import java.util.Scanner;

import java.util.ArrayList;

import Assignment01.XeMay;

import java.util.Collections;

import java.util.Comparator;


/**

 *

 * @author Minh

 */

public class XeMayHaNoi extends XeMay {

    Integer n;

    ArrayList<XeMay> xemayhanoi = new ArrayList<>();

    

    public XeMayHaNoi()

    {

        

    }


    public XeMayHaNoi(Integer n) {

        this.n = n;

    }


    public XeMayHaNoi(Integer n, String bienso, String loaixe, String mauxe, Float giatien) {

        super(bienso, loaixe, mauxe, giatien);

        this.n = n;

    }


    public Integer getN() {

        return n;

    }


    public void setN(Integer n) {

        this.n = n;

    }


    public ArrayList<XeMay> getXemayhanoi() {

        return xemayhanoi;

    }


    public void setXemayhanoi(ArrayList<XeMay> xemayhanoi) {

        this.xemayhanoi = xemayhanoi;

    }

    

    @Override

    public void nhap()

    {

        System.out.println("Nhap vao so luong xe");

        Scanner scan = new Scanner(System.in);

        n = Integer.parseInt(scan.nextLine());

        for ( int i = 0 ; i < n ; i++)

        {

            XeMay xemayhn = new XeMay();

            xemayhn.nhap();

            xemayhanoi.add(xemayhn);

        }

    }

    @Override

    public void hienthi()

    {

        System.out.println("Hien thi danh sach xe");

        for ( int i = 0; i < xemayhanoi.size() ; i++)

        {

            xemayhanoi.get(i).hienthi();

        }

        

    }

  public void sapxep()

    {

        Collections.sort(xemayhanoi, new Comparator<XeMay>(){

            @Override

            public int compare(XeMay o1 , XeMay o2){

                int t1 = Integer.parseInt(o1.getBienso());

                int t2 = Integer.parseInt(o2.getBienso());

                if (t1 > t2)

                {

                    return 1;

                }

                return -1;

            }

        });

        for (int i = 0; i < xemayhanoi.size(); i++)

        {

            xemayhanoi.get(i).hienthi();

        }

        

    }

 

   public void timkiem()

    {

        Scanner scan = new Scanner(System.in);

        System.out.println("nhap thong tin bien so xe");

        String bsx = scan.nextLine();

        for (int i = 0; i < xemayhanoi.size() ; i++)

        {

            if(xemayhanoi.get(i).getBienso().equalsIgnoreCase(bsx)){

                xemayhanoi.get(i).hienthi();

            }

        }

    } 

   public void thongke(){

       System.out.println(xemayhanoi.size());

   }

}


Ixe
/*
 * 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 Assignment01;

/**
 *
 * @author Minh
 */
public interface IXe {
    public void nhap();
    public void hienthi();
    
}
XeMay
/*
 * 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 Assignment01;
import java.util.Scanner;
/**
 *
 * @author Minh
 */
public class XeMay implements IXe {
    String bienso;
    String loaixe;
    String mauxe;
    Float giatien;
    
    public XeMay(){
        
    }

    public XeMay(String bienso, String loaixe, String mauxe, Float giatien) {
        this.bienso = bienso;
        this.loaixe = loaixe;
        this.mauxe = mauxe;
        this.giatien = giatien;
    }

    public String getBienso() {
        return bienso;
    }

    public void setBienso(String bienso) {
        this.bienso = bienso;
    }

    public String getLoaixe() {
        return loaixe;
    }

    public void setLoaixe(String loaixe) {
        this.loaixe = loaixe;
    }

    public String getMauxe() {
        return mauxe;
    }

    public void setMauxe(String mauxe) {
        this.mauxe = mauxe;
    }

    public Float getGiatien() {
        return giatien;
    }

    public void setGiatien(Float giatien) {
        this.giatien = giatien;
    }
    @Override
    public void nhap()
    {
        Scanner scan =new Scanner(System.in);
        bienso = scan.nextLine();
        loaixe = scan.nextLine();
        mauxe = scan.nextLine();
        giatien = Float.parseFloat(scan.nextLine());
    }
    @Override
    public void hienthi()
    {
        System.out.println(toString());
    }

    @Override
    public String toString() {
        return "XeMay{" + "bienso=" + bienso + ", loaixe=" + loaixe + ", mauxe=" + mauxe + ", giatien=" + giatien + '}';
    }
    
}





Minh Nghia [T1907A]
Minh Nghia

2020-03-14 14:45:10



/*
 * 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 xeco.info;

import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class XeMay implements IXe{
    String bienso;
    String loaixe;
    String mauxe;
    float giatien;

    public XeMay() {
    }

    public XeMay(String bienso, String loaixe, String mauxe, float giatien) {
        this.bienso = bienso;
        this.loaixe = loaixe;
        this.mauxe = mauxe;
        this.giatien = giatien;
    }

    public String getBienso() {
        return bienso;
    }

    public void setBienso(String bienso) {
        this.bienso = bienso;
    }

    public String getLoaixe() {
        return loaixe;
    }

    public void setLoaixe(String loaixe) {
        this.loaixe = loaixe;
    }

    public String getMauxe() {
        return mauxe;
    }

    public void setMauxe(String mauxe) {
        this.mauxe = mauxe;
    }

    public float getGiatien() {
        return giatien;
    }
   
    public void setGiatien(float giatien) {
        this.giatien = giatien;
    }
    @Override
    public void input(){
        Scanner scan = new Scanner(System.in);
        System.out.println("Nhap bien so:");
        bienso = scan.nextLine();
        System.out.println("Nhap loai xe:");
        loaixe = scan.nextLine();
        System.out.println("Nhap mau xe:");
        mauxe = scan.nextLine();
        System.out.println("Nhap gia tien:");
        giatien = Float.parseFloat(scan.nextLine());
    }
    @Override
    public void display(){
        System.out.println("Bien so:" + bienso);
        System.out.println("Loai xe:" + loaixe);
        System.out.println("Mau xe:" + mauxe);
        System.out.println("Gia tien:" + giatien);
    }
    
}



/*
 * 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 xeco.info;

/**
 *
 * @author Administrator
 */
public interface IXe {
    
    
    public void input();
    
    
    public void display();
}



/*
 * 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 quanlichung.xemay;

import hanoi.xemay.XeMayHaNoi;
import hoabinh.xemay.XeMayHoaBinh;
import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class QuanLyChung {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int choose,n;
        ArrayList<XeMayHoaBinh> HBList = new ArrayList<>();
        ArrayList<XeMayHaNoi> HNList = new ArrayList<>();
        XeMayHoaBinh xmhb = new XeMayHoaBinh();
        XeMayHaNoi xmhn = new XeMayHaNoi();
        
        do{
            menu();
            choose = Integer.parseInt(scan.nextLine());
            switch(choose){
                case 1:                    
                    xmhb.input();                     
                    break;
                case 2:
                    xmhn.input();                  
                    break;
                case 3:
                    System.out.println("1. Hoa Binh");
                    System.out.println("2. Ha Noi");
                    System.out.println("Choose:");
                    n = Integer.parseInt(scan.nextLine());
                    switch(choose){
                        case 1:
                            xmhb.sort();
                            break;
                        case 2:
                            xmhn.sort();
                            break;
                        default:
                            break;
                    }
                    break;
                case 4:
                    System.out.println("1. Hoa Binh");
                    System.out.println("2. Ha Noi");
                    System.out.println("Choose:");
                    n = Integer.parseInt(scan.nextLine());
                    switch(choose){
                        case 1:
                            xmhb.search();
                            break;
                        case 2:
                            xmhn.search();
                            break;
                        default:
                            break;
                    }
                    break;
                case 5:
                    System.out.println("1. Hoa Binh");
                    System.out.println("2. Ha Noi");
                    System.out.println("Choose:");
                    n = Integer.parseInt(scan.nextLine());
                    switch(choose){
                        case 1:
                            xmhb.thongKeSL();
                            break;
                        case 2:
                            xmhn.thongKeSL();
                            break;
                        default:
                            break;
                    }
                    break;
                case 6:
                    System.out.println("Thoat.");
                    break;
                default:
                    System.out.println("INPUT FAILED !!!");
                    break;
            }
        }while(choose != 6);
        
    }
    
    public static void menu(){
        System.out.println("1. Nhập thông tin cho n xe máy tại tỉnh Hòa Bình.");
        System.out.println("2. Nhập thông tin cho n xe máy tại tỉnh Hà Nội.");
        System.out.println("3. Sắp xếp danh sách tăng theo biển số xe.");
        System.out.println("4. Tìm kiếm thông tin xe theo biển số xe.");
        System.out.println("5. Thống kê số lượng xe đang quản lý.");
        System.out.println(" 6. Thoát");
    }
}



/*
 * 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 hoabinh.xemay;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import java.util.Scanner;
import xeco.info.XeMay;

/**
 *
 * @author Administrator
 */
public class XeMayHoaBinh extends XeMay{
    
    Scanner scan = new Scanner(System.in);
    int n;   
    ArrayList<XeMay> xeMayHBList = new ArrayList<>();

    public XeMayHoaBinh() {
    }

    public XeMayHoaBinh(int n, String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
        this.n = n;
    }
    
    @Override
    public void input(){
        System.out.println("Nhap so luong xe may HB:");
        n = Integer.parseInt(scan.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xemayhb = new XeMay();
            xemayhb.input();
            xeMayHBList.add(xemayhb);
        }
    }
    @Override
    public void display(){
        System.out.println("Danh sach xe may HB");
        for (int i = 0; i < xeMayHBList.size(); i++) {
            xeMayHBList.get(i).display();
        }
    }
    public void sort(){
        Collections.sort(xeMayHBList, new Comparator<XeMay>() {
            @Override
            public int compare(XeMay o1, XeMay o2) {
                if(o1.getBienso().equalsIgnoreCase(o2.getBienso())){
                    return 1;
                }return -1;
            }
        });
        display();
        }
    public void search(){
        System.out.println("Nhap bien so xe can tim:");
        String bienSo = scan.nextLine();
        for (int i = 0; i < xeMayHBList.size(); i++) {
            if(xeMayHBList.get(i).getBienso().equalsIgnoreCase(bienSo)){
                xeMayHBList.get(i).display();
            }
        }
    }
    public void thongKeSL(){
        System.out.println("So luong xe quan ly tai HB :" + xeMayHBList.size());
    }
    
    
}



/*
 * 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 hanoi.xemay;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
import xeco.info.XeMay;

/**
 *
 * @author Administrator
 */
public class XeMayHaNoi extends XeMay {
    Scanner scan = new Scanner(System.in);
    int n;
    ArrayList<XeMay> xeMayHNList = new ArrayList<>();

    public XeMayHaNoi() {
    }

    public XeMayHaNoi(int n) {
        this.n = n;
    }

    public XeMayHaNoi(int n, String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
        this.n = n;
    }
    
    @Override
    public void input(){
        System.out.println("Nhap so luong xe may HN:");
        n = Integer.parseInt(scan.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xemayhn = new XeMay();
            xemayhn.input();
            xeMayHNList.add(xemayhn);
        }
    }
    @Override
    public void display(){
        System.out.println("Danh sach xe may HN :");
        for (int i = 0; i < xeMayHNList.size(); i++) {
            xeMayHNList.get(i).display();
        }
    }
    
    
        public void sort(){
        Collections.sort(xeMayHNList, new Comparator<XeMay>() {
            @Override
            public int compare(XeMay o1, XeMay o2) {
                if(o1.getBienso().equalsIgnoreCase(o2.getBienso())){
                    return 1;
                }return -1;
            }
        });
        
        display();
        
        }
        
    public void search(){
        System.out.println("Nhap bien so xe can tim:");
        String bienSo = scan.nextLine();
        for (int i = 0; i < xeMayHNList.size(); i++) {
            if(xeMayHNList.get(i).getBienso().equalsIgnoreCase(bienSo)){
                xeMayHNList.get(i).display();
            }
        }
    }
    public void thongKeSL(){
        System.out.println("So luong xe quan ly tai HB :" + xeMayHNList.size());
    }
}



Phan Bạch Tùng Dương [T1907A]
Phan Bạch Tùng Dương

2020-03-14 07:07:04



/*
 * 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 QLXeco;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class Main {
    public static void main(String[] args) {
        XeMayHoaBinh xmHB = new XeMayHoaBinh();
        XeMayHaNoi xmHN = new XeMayHaNoi();
        int choose;
        Scanner scanner = new Scanner(System.in);
        do {
            showmenu();
            choose = scanner.nextInt();
            switch (choose) {
                case 1:
                    xmHB.nhap();
                    xmHB.hienthi();
                    break;
                case 2:
                    xmHN.nhap();
                    xmHN.hienthi();
                    break;
                case 3:
                    int index;
                    do {
                        System.out.println("1. Hoa Binh");
                        System.out.println("2. Ha Noi");
                        index = scanner.nextInt();
                        switch (index) {
                            case 1:
                                xmHB.sapxep();
                                xmHB.hienthi();
                                break;
                            case 2:
                                xmHN.sapxep();
                                xmHN.hienthi();
                                break;
                            default:
                                System.err.println("Vui long chon lai : ");
                                break;
                        }
                    } while (index < 1 || index > 2);
                    break;
                case 4:
                    int bienso;
                    do {
                        System.out.println("1. Hoa Binh");
                        System.out.println("2. Ha Noi");
                        bienso = scanner.nextInt();
                        switch (bienso) {
                            case 1:
                                xmHB.timkiem();
                                break;
                            case 2:
                                xmHN.timkiem();
                                break;
                            default:
                                System.err.println("Vui long chon lai : ");
                                break;
                        }
                    } while (bienso < 1 || bienso > 2);
                    break;
                case 5:
                    int soluong;
                    do {
                        System.out.println("1. Hoa Binh");
                        System.out.println("2. Ha Noi");
                        soluong = scanner.nextInt();
                        switch (soluong) {
                            case 1:
                                xmHB.soluongXe();
                                break;
                            case 2:
                                xmHN.soluongXe();
                                break;
                            default:
                                System.err.println("Vui long chon lai : ");
                                break;
                        }
                    } while (soluong < 1 || soluong > 2);
                    break;
                case 6:
                    System.out.println("Thoat thanh cong.");
                    break;
                default:
                    System.out.println("Cu phap sai,Vui long chon lai : ");
                    break;
            }

        } while (choose != 6);
    }

    public static void showmenu() {
        System.out.println("1. Nhap thong tin cho so xe may tai tinh Hoa Binh. ");
        System.out.println("2. Nhap thong tin cho so xe may tai tinh Ha Noi. ");
        System.out.println("3. Sap xep danh sach tang dan theo bien so xe. ");
        System.out.println("4. Tim kiem thong tin xe theo bien so xe. ");
        System.out.println("5. Thong ke so luong xe dang quan ly. ");
        System.out.println("6. Thoat.");
        System.out.println("Choose: ");
    }
}



/*
 * 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 QLXeco;

/**
 *
 * @author Admin
 */
public interface IXe {
    public void nhap();
    public void hienthi();
}



/*
 * 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 QLXeco;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class XeMay implements IXe {
    public String bienso,loaixe, mauxe;
    public float giatien;

    public XeMay() {
    }

    public XeMay(String bienso, String loaixe, String mauxe, float giatien) {
        this.bienso = bienso;
        this.loaixe = loaixe;
        this.mauxe = mauxe;
        this.giatien = giatien;
    }
    
    @Override
    public void nhap(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("Nhap thong tin xe: ");
        System.out.println("Nhap bien so: ");
        bienso = scanner.nextLine();
        System.out.println("Nhap loai xe: ");
        loaixe = scanner.nextLine();
        System.out.println("Nhap mau xe: ");
        mauxe = scanner.nextLine();
        System.out.println("Nhap gia tien: ");
        giatien = Integer.parseInt(scanner.nextLine());
    }
    
    @Override
    public void hienthi(){
        System.out.println(toString());
    }
    
    @Override
    public String toString() {
        return "XeMay{" + "bienso=" + bienso + ", loaixe=" + loaixe + ", mauxe=" + mauxe + ", giatien=" + giatien + '}';
    }

    public String getBienso() {
        return bienso;
    }

    public void setBienso(String bienso) {
        this.bienso = bienso;
    }

    public String getLoaixe() {
        return loaixe;
    }

    public void setLoaixe(String loaixe) {
        this.loaixe = loaixe;
    }

    public String getMauxe() {
        return mauxe;
    }

    public void setMauxe(String mauxe) {
        this.mauxe = mauxe;
    }

    public float getGiatien() {
        return giatien;
    }

    public void setGiatien(float giatien) {
        this.giatien = giatien;
    } 
}



/*
 * 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 QLXeco;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class XeMayHaNoi extends XeMay{
    public int n;
    public ArrayList<XeMay> mangXe = new ArrayList<>();

    public XeMayHaNoi() {
    }
     public XeMayHaNoi(String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
    }
    @Override
    public void hienthi() {
        System.out.println("Danh sach xe may Ha Noi");
        mangXe.forEach((mangXe1) -> {
            mangXe1.hienthi();
        });
    }
    @Override
    public void nhap() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap thong tin cho n xe may o tinh Ha Noi");
        n = Integer.parseInt(sc.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xm = new XeMay();
            xm.nhap();
            mangXe.add(xm);
        }
    }
     public void sapxep() {
        Collections.sort(mangXe, (XeMay o1, XeMay o2) -> o1.getBienso().compareTo(o2.getBienso()));
    }

    public void soluongXe() {
        System.out.println("So luong xe quan li o Ha Noi:" + mangXe.size());
    }

    public void timkiem() {
        int a = -1;
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap bien so can tim");
        String bienso = sc.nextLine();
        for (int i = 0; i < mangXe.size(); i++) {
            if (mangXe.get(i).getBienso().equalsIgnoreCase(bienso)) {
                a = i;
            }
        }
        if (a != -1) {
            mangXe.get(a).hienthi();
        } else {
            System.out.println("Khong tim thay bien so" + bienso);
        }
    }

    public int getN() {
        return n;
    }

    public void setN(int n) {
        this.n = n;
    }

    public ArrayList<XeMay> getMangXe() {
        return mangXe;
    }

    public void setMangXe(ArrayList<XeMay> mangXe) {
        this.mangXe = mangXe;
    }

}



/*
 * 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 QLXeco;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class XeMayHoaBinh extends XeMay {
     private int n;
    private ArrayList<XeMay> mangXe = new ArrayList<>();

    public XeMayHoaBinh() {
    }

    public XeMayHoaBinh(String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
    }

    @Override
    public void hienthi() {
        System.out.println("Danh sach xe may Hoa Binh");
        for (XeMay mangXe1 : mangXe) {
            mangXe1.hienthi();
        }
    }

    public void timkiem() {
        int a = -1;
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap bien so can tim");
        String bienso = sc.nextLine();
        for (int i = 0; i < mangXe.size(); i++) {
            if (mangXe.get(i).getBienso().equalsIgnoreCase(bienso)) {
                a = i;
            }
        }
        if (a != -1) {
            mangXe.get(a).hienthi();
        } else {
            System.out.println("Khong tim thay bien so" + bienso);
        }
    }

    @Override
    public void nhap() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap thong tin cho n xe may o tinh Hoa Binh");
        n = Integer.parseInt(sc.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xm = new XeMay();
            xm.nhap();
            mangXe.add(xm);
        }
    }

    public void soluongXe() {
        System.out.println("So luong xe quan li o Hoa Binh:" + mangXe.size());
    }

    public int getN() {
        return n;
    }

    public void setN(int n) {
        this.n = n;
    }

    public ArrayList<XeMay> getMangXe() {
        return mangXe;
    }

    public void setMangXe(ArrayList<XeMay> mangXe) {
        this.mangXe = mangXe;
    }

    public void sapxep() {
        Collections.sort(mangXe, (XeMay o1, XeMay o2) -> o1.getBienso().compareTo(o2.getBienso()));
    }
}



Phí Văn Long [T1907A]
Phí Văn Long

2020-03-14 07:00:45

main :



/*
 * 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 Quanlixe;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class Main {
    public static void main(String[] args) {
        XeMayHB xmHB = new XeMayHB();
        XeMayHN xmHN = new XeMayHN();
        int choose;
        Scanner scanner = new Scanner(System.in);
        do {
            showmenu();
            choose = scanner.nextInt();
            switch (choose) {
                case 1:
                    xmHB.nhap();
                    xmHB.hienthi();
                    break;
                case 2:
                    xmHN.nhap();
                    xmHN.hienthi();
                    break;
                case 3:
                    int index;
                    do {
                        System.out.println("1.Hoa Binh");
                        System.out.println("2.Ha Noi");
                        index = scanner.nextInt();
                        switch (index) {
                            case 1:
                                xmHB.sapxep();
                                xmHB.hienthi();
                                break;
                            case 2:
                                xmHN.sapxep();
                                xmHN.hienthi();
                                break;
                            default:
                                System.err.println("Chon lai di");
                                break;
                        }
                    } while (index < 1 || index > 2);
                    break;
                case 4:
                    int bienso;
                    do {
                        System.out.println("1.Hoa Binh");
                        System.out.println("2.Ha Noi");
                        bienso = scanner.nextInt();
                        switch (bienso) {
                            case 1:
                                xmHB.timkiem();
                                break;
                            case 2:
                                xmHN.timkiem();
                                break;
                            default:
                                System.err.println("Chon lai di");
                                break;
                        }
                    } while (bienso < 1 || bienso > 2);
                    break;
                case 5:
                    int soluong;
                    do {
                        System.out.println("1.Hoa Binh");
                        System.out.println("2.Ha Noi");
                        soluong = scanner.nextInt();
                        switch (soluong) {
                            case 1:
                                xmHB.soluongXe();
                                break;
                            case 2:
                                xmHN.soluongXe();
                                break;
                            default:
                                System.err.println("Chon lai di");
                                break;
                        }
                    } while (soluong < 1 || soluong > 2);
                    break;
                case 6:
                    System.out.println("Thoat thanh cong");
                    break;
                default:
                    System.out.println("Nhap sai roi ,nhap lai di ban eii");
                    break;
            }

        } while (choose != 6);
    }

    public static void showmenu() {
        System.out.println("1.Nhap thong tin cho so xe may tai tinh Hoa Binh.");
        System.out.println("2. Nhap thong tin cho so xe may tai tinh Ha Noi.");
        System.out.println("3. Sap xep danh sach tang dan theo bien so xe.");
        System.out.println("4. Tim kiem thong tin xe theo bien so xe.");
        System.out.println("5. Thong ke so luong xe dang quan ly.");
        System.out.println("6:Thoat");
        System.out.println("Choose:");
    }
}

IXe:



/*
 * 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 Quanlixe;

/**
 *
 * @author Admin
 */
public interface IXe {
    public void nhap();
    public void hienthi();
}

XeMay:



/*
 * 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 Quanlixe;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class XeMay implements IXe {
    public String bienso,loaixe, mauxe;
    public float giatien;

    public XeMay() {
    }

    public XeMay(String bienso, String loaixe, String mauxe, float giatien) {
        this.bienso = bienso;
        this.loaixe = loaixe;
        this.mauxe = mauxe;
        this.giatien = giatien;
    }
    
    @Override
    public void nhap(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("Nhap thong tin xe: ");
        System.out.println("Nhap bien so: ");
        bienso = scanner.nextLine();
        System.out.println("Nhap loai xe: ");
        loaixe = scanner.nextLine();
        System.out.println("Nhap mau xe: ");
        mauxe = scanner.nextLine();
        System.out.println("Nhap gia tien: ");
        giatien = Integer.parseInt(scanner.nextLine());
    }
    
    @Override
    public void hienthi(){
        System.out.println(toString());
    }
    
    @Override
    public String toString() {
        return "XeMay{" + "bienso=" + bienso + ", loaixe=" + loaixe + ", mauxe=" + mauxe + ", giatien=" + giatien + '}';
    }

    public String getBienso() {
        return bienso;
    }

    public void setBienso(String bienso) {
        this.bienso = bienso;
    }

    public String getLoaixe() {
        return loaixe;
    }

    public void setLoaixe(String loaixe) {
        this.loaixe = loaixe;
    }

    public String getMauxe() {
        return mauxe;
    }

    public void setMauxe(String mauxe) {
        this.mauxe = mauxe;
    }

    public float getGiatien() {
        return giatien;
    }

    public void setGiatien(float giatien) {
        this.giatien = giatien;
    }
    
    

   
    
    
}

XeMayHN:



/*
 * 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 Quanlixe;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class XeMayHN extends XeMay{
    public int n;
    public ArrayList<XeMay> mangXe = new ArrayList<>();

    public XeMayHN() {
    }
     public XeMayHN(String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
    }
    @Override
    public void hienthi() {
        System.out.println("Danh sach xe may Ha Noi");
        mangXe.forEach((mangXe1) -> {
            mangXe1.hienthi();
        });
    }
    @Override
    public void nhap() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap thong tin cho n xe may o tinh Ha Noi");
        n = Integer.parseInt(sc.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xm = new XeMay();
            xm.nhap();
            mangXe.add(xm);
        }
    }
     public void sapxep() {
        Collections.sort(mangXe, (XeMay o1, XeMay o2) -> o1.getBienso().compareTo(o2.getBienso()));
    }

    public void soluongXe() {
        System.out.println("So luong xe quan li o Ha Noi:" + mangXe.size());
    }

    public void timkiem() {
        int a = -1;
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap bien so can tim");
        String bienso = sc.nextLine();
        for (int i = 0; i < mangXe.size(); i++) {
            if (mangXe.get(i).getBienso().equalsIgnoreCase(bienso)) {
                a = i;
            }
        }
        if (a != -1) {
            mangXe.get(a).hienthi();
        } else {
            System.out.println("Khong tim thay xe co bien so: " + bienso);
        }
    }

    public int getN() {
        return n;
    }

    public void setN(int n) {
        this.n = n;
    }

    public ArrayList<XeMay> getMangXe() {
        return mangXe;
    }

    public void setMangXe(ArrayList<XeMay> mangXe) {
        this.mangXe = mangXe;
    }

}

XeMayHB:



/*
 * 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 Quanlixe;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class XeMayHB extends XeMay {
     private int n;
    private ArrayList<XeMay> mangXe = new ArrayList<>();

    public XeMayHB() {
    }

    public XeMayHB(String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
    }

    @Override
    public void hienthi() {
        System.out.println("Danh sach xe may Hoa Binh");
        for (XeMay mangXe1 : mangXe) {
            mangXe1.hienthi();
        }
    }

    public void timkiem() {
        int a = -1;
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap bien so can tim");
        String bienso = sc.nextLine();
        for (int i = 0; i < mangXe.size(); i++) {
            if (mangXe.get(i).getBienso().equalsIgnoreCase(bienso)) {
                a = i;
            }
        }
        if (a != -1) {
            mangXe.get(a).hienthi();
        } else {
            System.out.println("Khong tim thay xe co bien so: " + bienso);
        }
    }

    @Override
    public void nhap() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap thong tin cho n xe may o tinh Hoa Binh");
        n = Integer.parseInt(sc.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xm = new XeMay();
            xm.nhap();
            mangXe.add(xm);
        }
    }

    public void soluongXe() {
        System.out.println("So luong xe quan li o Hoa Binh:" + mangXe.size());
    }

    public int getN() {
        return n;
    }

    public void setN(int n) {
        this.n = n;
    }

    public ArrayList<XeMay> getMangXe() {
        return mangXe;
    }

    public void setMangXe(ArrayList<XeMay> mangXe) {
        this.mangXe = mangXe;
    }

    public void sapxep() {
        Collections.sort(mangXe, (XeMay o1, XeMay o2) -> o1.getBienso().compareTo(o2.getBienso()));
    }
}



thienphu [T1907A]
thienphu

2020-03-14 02:12:52



/*
 * 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 QuanLiXeCo2;

/**
 *
 * @author Thien Phu
 */
public interface IXe {

    void nhap();

    void hienthi();
}



/*
 * 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 QuanLiXeCo2;

import java.util.Scanner;

/**
 *
 * @author Thien Phu
 */
public class XeMay implements IXe {

    private String bienso, loaixe, mauxe;
    private float giatien;

    public XeMay() {
    }

    public XeMay(String bienso, String loaixe, String mauxe, float giatien) {
        this.bienso = bienso;
        this.loaixe = loaixe;
        this.mauxe = mauxe;
        this.giatien = giatien;
    }

    @Override
    public void nhap() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap thong tin xe");
        System.out.println("Nhap bien so: ");
        bienso = sc.nextLine();
        System.out.println("Nhap loai xe");
        loaixe = sc.nextLine();
        System.out.println("Nhap mau xe");
        mauxe = sc.nextLine();
        System.out.println("Nhap gia tien");
        giatien = Integer.parseInt(sc.nextLine());
    }

    @Override
    public void hienthi() {
        System.out.println(toString());
    }

    @Override
    public String toString() {
        return "XeMay{" + "bienso=" + bienso + ", loaixe=" + loaixe + ", mauxe=" + mauxe + ", giatien=" + giatien + '}';
    }

    public String getBienso() {
        return bienso;
    }

    public void setBienso(String bienso) {
        this.bienso = bienso;
    }

    public String getLoaixe() {
        return loaixe;
    }

    public void setLoaixe(String loaixe) {
        this.loaixe = loaixe;
    }

    public String getMauxe() {
        return mauxe;
    }

    public void setMauxe(String mauxe) {
        this.mauxe = mauxe;
    }

    public float getGiatien() {
        return giatien;
    }

    public void setGiatien(float giatien) {
        this.giatien = giatien;
    }
}



/*
 * 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 QuanLiXeCo2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

/**
 *
 * @author Thien Phu
 */
public class XeMayHN extends XeMay {

    private int n;
    private ArrayList<XeMay> mangXe = new ArrayList<>();

    public XeMayHN() {
    }

    public XeMayHN(String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
    }

    @Override
    public void hienthi() {
        System.out.println("Danh sach xe may Ha Noi");
        for (XeMay mangXe1 : mangXe) {
            mangXe1.hienthi();
        }
    }

    @Override
    public void nhap() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap thong tin cho n xe may o tinh Ha Noi");
        n = Integer.parseInt(sc.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xm = new XeMay();
            xm.nhap();
            mangXe.add(xm);
        }
    }

    public void sapxep() {
        Collections.sort(mangXe, new Comparator<XeMay>() {

            @Override
            public int compare(XeMay o1, XeMay o2) {
                return o1.getBienso().compareTo(o2.getBienso());
            }
        });
    }

    public void soluongXe() {
        System.out.println("So luong xe quan li o Ha Noi:" + mangXe.size());
    }

    public void timkiem() {
        int a = -1;
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap bien so can tim");
        String bienso = sc.nextLine();
        for (int i = 0; i < mangXe.size(); i++) {
            if (mangXe.get(i).getBienso().equalsIgnoreCase(bienso)) {
                a = i;
            }
        }
        if (a != -1) {
            mangXe.get(a).hienthi();
        } else {
            System.out.println("Khong tim thay xe co bien so: " + bienso);
        }
    }

    public int getN() {
        return n;
    }

    public void setN(int n) {
        this.n = n;
    }

    public ArrayList<XeMay> getMangXe() {
        return mangXe;
    }

    public void setMangXe(ArrayList<XeMay> mangXe) {
        this.mangXe = mangXe;
    }

}



package QuanLiXeCo2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

/**
 *
 * @author Thien Phu
 */
public class XeMayHoaBInh extends XeMay {

    private int n;
    private ArrayList<XeMay> mangXe = new ArrayList<>();

    public XeMayHoaBInh() {
    }

    public XeMayHoaBInh(String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
    }

    @Override
    public void hienthi() {
        System.out.println("Danh sach xe may Hoa Binh");
        for (XeMay mangXe1 : mangXe) {
            mangXe1.hienthi();
        }
    }

    public void timkiem() {
        int a = -1;
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap bien so can tim");
        String bienso = sc.nextLine();
        for (int i = 0; i < mangXe.size(); i++) {
            if (mangXe.get(i).getBienso().equalsIgnoreCase(bienso)) {
                a = i;
            }
        }
        if (a != -1) {
            mangXe.get(a).hienthi();
        } else {
            System.out.println("Khong tim thay xe co bien so: " + bienso);
        }
    }

    @Override
    public void nhap() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap thong tin cho n xe may o tinh Hoa Binh");
        n = Integer.parseInt(sc.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xm = new XeMay();
            xm.nhap();
            mangXe.add(xm);
        }
    }

    public void soluongXe() {
        System.out.println("So luong xe quan li o Hoa Binh:" + mangXe.size());
    }

    public int getN() {
        return n;
    }

    public void setN(int n) {
        this.n = n;
    }

    public ArrayList<XeMay> getMangXe() {
        return mangXe;
    }

    public void setMangXe(ArrayList<XeMay> mangXe) {
        this.mangXe = mangXe;
    }

    public void sapxep() {
        Collections.sort(mangXe, new Comparator<XeMay>() {

            @Override
            public int compare(XeMay o1, XeMay o2) {
                return o1.getBienso().compareTo(o2.getBienso());
            }
        });
    }
}



/*
 * 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 QuanLiXeCo2;

import java.util.Scanner;

/**
 *
 * @author Thien Phu
 */
public class TestMain {

    public static void main(String[] args) {
        XeMayHoaBInh xmHB = new XeMayHoaBInh();
        XeMayHN xmHN = new XeMayHN();
        int choose;
        Scanner sc = new Scanner(System.in);
        do {
            showmenu();
            choose = sc.nextInt();
            switch (choose) {
                case 1:
                    xmHB.nhap();
                    xmHB.hienthi();
                    break;
                case 2:
                    xmHN.nhap();
                    xmHN.hienthi();
                    break;
                case 3:
                    int index;
                    do {
                        System.out.println("1.HoaBinh");
                        System.out.println("2.HaNoi");
                        index = sc.nextInt();
                        switch (index) {
                            case 1:
                                xmHB.sapxep();
                                xmHB.hienthi();
                                break;
                            case 2:
                                xmHN.sapxep();
                                xmHN.hienthi();
                                break;
                            default:
                                System.err.println("Chon lai di");
                                break;
                        }
                    } while (index < 1 || index > 2);
                    break;
                case 4:
                    int bienso;
                    do {
                        System.out.println("1.HoaBinh");
                        System.out.println("2.HaNoi");
                        bienso = sc.nextInt();
                        switch (bienso) {
                            case 1:
                                xmHB.timkiem();
                                break;
                            case 2:
                                xmHN.timkiem();
                                break;
                            default:
                                System.err.println("Chon lai di");
                                break;
                        }
                    } while (bienso < 1 || bienso > 2);
                    break;
                case 5:
                    int soluong;
                    do {
                        System.out.println("1.HoaBinh");
                        System.out.println("2.HaNoi");
                        soluong = sc.nextInt();
                        switch (soluong) {
                            case 1:
                                xmHB.soluongXe();
                                break;
                            case 2:
                                xmHN.soluongXe();
                                break;
                            default:
                                System.err.println("Chon lai di");
                                break;
                        }
                    } while (soluong < 1 || soluong > 2);
                    break;
                case 6:
                    System.out.println("Thoat thanh cong");
                    break;
                default:
                    System.out.println("Nhap lai di");
                    break;
            }

        } while (choose != 6);
    }

    public static void showmenu() {
        System.out.println("1. Nhập thông tin cho n xe máy tại tỉnh Hòa Bình.");
        System.out.println("2. Nhập thông tin cho n xe máy tại tỉnh Hà Nội.");
        System.out.println("3. Sắp xếp danh sách tăng theo biển số xe.");
        System.out.println("4. Tìm kiếm thông tin xe theo biển số xe.");
        System.out.println("5. Thống kê số lượng xe đang quản lý.");
        System.out.println("6:Thoat");
        System.out.println("Choose:");
    }
}



Luong Dinh Dai [T1907A]
Luong Dinh Dai

2020-03-13 15:30:46



/*
 * 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 xe.info;

import java.util.Scanner;

/**
 *
 * @author FATE STORE
 */
public class XeMay implements IXe{
    String bienso;
    String loaixe;
    String mauxe;
    float giatien;

    public XeMay() {
    }

    public XeMay(String bienso, String loaixe, String mauxe, float giatien) {
        this.bienso = bienso;
        this.loaixe = loaixe;
        this.mauxe = mauxe;
        this.giatien = giatien;
    }

    public String getBienso() {
        return bienso;
    }

    public void setBienso(String bienso) {
        this.bienso = bienso;
    }

    public String getLoaixe() {
        return loaixe;
    }

    public void setLoaixe(String loaixe) {
        this.loaixe = loaixe;
    }

    public String getMauxe() {
        return mauxe;
    }

    public void setMauxe(String mauxe) {
        this.mauxe = mauxe;
    }

    public float getGiatien() {
        return giatien;
    }

    public void setGiatien(float giatien) {
        this.giatien = giatien;
    }

    @Override
    public String toString() {
        return "XeMay{" + "bienso=" + bienso + ", loaixe=" + loaixe + ", mauxe=" + mauxe + ", giatien=" + giatien + '}';
    }

    
    @Override
    public void nhap() {
        Scanner sc = new Scanner(System.in);
        System.out.println("nhap bien so: ");
        bienso = sc.nextLine();
        System.out.println("nhap loai xe: ");
        loaixe = sc.nextLine();
        System.out.println("nhap mau xe: ");
        mauxe = sc.nextLine();
        System.out.println("nhap gia tien: ");
        giatien = sc.nextFloat();
    }

    
    @Override
    public void hienthi() {
        System.out.print(toString());
        System.out.println("");
    }
    
}



/*
 * 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 xe.info;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

/**
 *
 * @author FATE STORE
 */
public class XeMayHaNoi extends XeMay{
    int n;
    ArrayList<XeMay> lstxehn = new ArrayList<>();
    public XeMayHaNoi() {
    }

    public XeMayHaNoi(int n, String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
        this.n = n;
    }

    @Override
    public void hienthi() {
        for(XeMay xemay: lstxehn){
            xemay.hienthi();
        }
    }

   

    @Override
    public void nhap() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap so luong xe: ");
        n = sc.nextInt();
        System.out.println("Nhap Thong tin xe ");
        for (int i = 1; i <= n; i++) {
            System.out.printf("thong tin xe may thu %d ", i);
            System.out.println("");
            XeMay xemay = new XeMay();
            xemay.nhap();
            lstxehn.add(xemay);
        }
    }
   public void sapxep() {
        Collections.sort(lstxehn, new Comparator<XeMay>() {
            @Override
            public int compare(XeMay xeMay, XeMay t1) {
                if (xeMay.getBienso().equalsIgnoreCase(t1.getBienso())) {
                    return 1;
                }
                return -1;
            }
        });
        hienthi();
    }
   public XeMay Timkiem(String bienso){
       for(XeMay xe: lstxehn){
           if(xe.getBienso().equalsIgnoreCase(bienso))
           {
               return xe;
           }
       }
       return null;
   }
}



/*
 * 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 xe.info;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

/**
 *
 * @author FATE STORE
 */
public class XeMayHoaBinh extends XeMay {

    int n;
    ArrayList<XeMay> lstxehb = new ArrayList<>();

    public XeMayHoaBinh() {
    }

    public XeMayHoaBinh(int n, String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
        this.n = n;
    }

    @Override
    public void hienthi() {
        for (XeMay xemay : lstxehb) {
            xemay.hienthi();
        }
    }

    @Override
    public void nhap() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap so luong xe: ");
        n = sc.nextInt();
        System.out.println("Nhap Thong tin xe ");
        for (int i = 1; i <= n; i++) {
            System.out.printf("thong tin xe may thu %d ", i);
            System.out.println("");
            XeMay xemay = new XeMay();
            xemay.nhap();
            lstxehb.add(xemay);
        }

    }

    public void sapxep() {
        Collections.sort(lstxehb, new Comparator<XeMay>() {
            @Override
            public int compare(XeMay xeMay, XeMay t1) {
                if (xeMay.getBienso().equalsIgnoreCase(t1.getBienso())) {
                    return 1;
                }
                return -1;
            }
        });
        hienthi();
    }

    public XeMay Timkiem(String bienso) {
        for (XeMay xe : lstxehb) {
            if (xe.getBienso().equalsIgnoreCase(bienso)) {
                return xe;
            }
        }
        return null;
    }

}



/*
 * 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 xe.info;

import java.util.Scanner;
import java01.Main;

/**
 *
 * @author FATE STORE
 */
public class QuanLyChung {
    public static void main(String[] args) {
        XeMayHoaBinh xehb = new XeMayHoaBinh();
        XeMayHaNoi xehn = new XeMayHaNoi();
        QuanLyChung mn = new QuanLyChung();
        int sw;
        do{
            mn.menu();
            Scanner sc = new Scanner(System.in);
            sw = sc.nextInt();
            sc.nextLine();
            switch(sw){
                case 1:{
                    xehb.nhap();
                    break;
                }
                case 2:{
                    xehn.nhap();
                    break;
                }
                case 3:{
                    System.out.print("=========================================
1: Hoa Binh: 
2: Ha Noi:
3: Thoat: 
 --- Lua Chon: ");
                    sw = sc.nextInt();
                    switch(sw){
                        case 1:{
                            xehb.sapxep();
                            break;
                        }
                        case 2:{
                            xehn.sapxep();
                        }
                        default:
                            break;
                    }
                    break;
                }
                case 4: {
                    System.out.print("=========================================
1: Hoa Binh: 
2: Ha Noi:
3: Thoat: 
 --- Lua Chon: ");
                    sw = sc.nextInt();
                    sc.nextLine();
                    switch (sw) {
                        case 1: {
                            System.out.println("bien so xe: ");
                            String bienso = sc.nextLine();
                            XeMay xemayhb = xehb.Timkiem(bienso);
                            System.out.println("XeMay{" + "bienso=" + xemayhb.getBienso() + ", loaixe=" + xemayhb.getLoaixe() + ", mauxe=" + xemayhb.getMauxe() + ", giatien=" + xemayhb.getGiatien() + '}');
                            break;
                        }
                        case 2: {
                            System.out.println("bien so xe: ");
                            String bienso = sc.nextLine();
                            XeMay xemayhn = xehn.Timkiem(bienso);
                            System.out.println("XeMay{" + "bienso=" + xemayhn.getBienso() + ", loaixe=" + xemayhn.getLoaixe() + ", mauxe=" + xemayhn.getMauxe() + ", giatien=" + xemayhn.getGiatien() + '}');
                            break;
                        }
                        default:
                            break;

                    }
                    break;
                }
                case 5:
                    System.out.print("=========================================
1: Hoa Binh: 
2: Ha Noi:
3: Thoat: 
 --- Lua Chon: ");
                    sw = sc.nextInt();
                    sc.nextLine();
                    switch(sw){
                        case 1:{
                            System.out.println("So luong xe dang quan ly: "+ xehb.lstxehb.size());
                            break;
                        }
                        case 2:{
                            System.out.println("So luong xe dang quan ly: "+ xehn.lstxehn.size());
                            break;
                        }
                        default:
                            break;
                    }
                    break;
            }
        } while (sw != 6);
    }
    public void menu(){
        System.out.print("=========================================
1: Nhap Thong Tin Cho N Xe May Tai Tinh Hoa Binh: 
2: Nhap Thong Tin Cho N Xe May Tai Tinh Ha Noi:
3: Sap Xep Danh Sach Tang Theo Bien So Xe: 
4: Tim Kiem Thong Tin Theo Bien So Xe: 
5: Thong Ke Luong Xe Dang Quan Ly: 
6: Thoat: 
 --- Lua Chon: ");
    }
}



Trương Công Vinh [T1907A]
Trương Công Vinh

2020-03-13 10:54:01



/*
 * 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 quanlychung.xemay;

import hoabinh.xemay.XeMayHoaBinh;
import hanoi.xemay.XeMayHaNoi;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class QuanLyChung {

    public static void main(String[] args) {
        XeMayHoaBinh xeHB = new XeMayHoaBinh();
        XeMayHaNoi xeHN = new XeMayHaNoi();
        Scanner scan = new Scanner(System.in);
        int c;
        String dp;
        do{
            menu();
            c= Integer.parseInt(scan.nextLine());
            switch(c){
                case 1:
                    xeHB.nhap();
                    break;
                case 2:
                    xeHN.nhap();
                    break;
                case 3:
                    System.out.println("1.Ha Noi");
                    System.out.println("2.Hoa Binh");
                    System.out.println("Chon : ");
                    c= Integer.parseInt(scan.nextLine());
                    switch(c){
                        case 1:
                            xeHN.sort();
                            break;
                        case 2:
                            xeHB.sort();
                            break;
                        default :
                            break;
                    }
                    break;
                case 4:
                    System.out.println("1.Ha Noi");
                    System.out.println("2.Hoa Binh");
                    System.out.println("Chon : ");
                    c= Integer.parseInt(scan.nextLine());
                    switch(c){
                        case 1:
                            xeHN.search();
                            break;
                        case 2:
                            xeHB.search();
                            break;
                        default :
                            break;
                    }
                    break;
                case 5:
                    System.out.println("1.Ha Noi");
                    System.out.println("2.Hoa Binh");
                    System.out.println("Chon : ");
                    c= Integer.parseInt(scan.nextLine());
                    switch(c){
                        case 1:
                            xeHN.thongkeSL();
                            break;
                        case 2:
                            xeHB.thongkeSL();
                            break;
                        default :
                            break;
                    }
                    break;
                case 6:
                    System.out.println("End !!");
                    break;
                default :
                    
                    break;
                
            }
        }while(c !=6);
    }

    public static void menu() {
          System.out.println("1. Nhập thông tin cho n xe máy tại tỉnh Hòa Bình.");
          System.out.println(" 2. Nhập thông tin cho n xe máy tại tỉnh Hà Nội.");
          System.out.println("3. Sắp xếp danh sách tăng theo biển số xe.");
          System.out.println("4. Tìm kiếm thông tin xe theo biển số xe.");
          System.out.println("  5. Thống kê số lượng xe đang quản lý. ");
          System.out.println("6. Thoát");
          System.out.print("\nChon : ");
    }
}



/*
 * 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 hoabinh.xemay;

import java.util.Scanner;
import xeco.info.XeMay;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
/**
 *
 * @author DELL
 */
public class XeMayHoaBinh extends XeMay {

    int n;
    Scanner scan = new Scanner(System.in);
    ArrayList<XeMay> listXe = new ArrayList<>();

    public XeMayHoaBinh() {
    }

    public XeMayHoaBinh(int n, String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
        this.n = n;
    }
    
    
    
    @Override
    public void nhap(){
        System.out.println("Nhap so xe may can quan ly (Hoa Binh) : ");
        n=Integer.parseInt(scan.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xemay = new XeMay();
            xemay.nhap();
            listXe.add(xemay);
          
        }
    }
    @Override
    public void hienthi(){
        System.out.println("Danh sach xe may tai Hoa Binh : \n");
        for (int i = 0; i < listXe.size(); i++) {
            listXe.get(i).hienthi();
        }
    }
    public void sort(){
        Collections.sort(listXe, new Comparator<XeMay>() {
            @Override
            public int compare(XeMay o1, XeMay o2) {
                if(o2.getBienso().equalsIgnoreCase(o2.getBienso())){
                    return 1;
                }return -1;
            }
            
        });
        hienthi();
    }
    public void thongkeSL(){
        System.out.println("So luong xe quan ly tai Hoa Binh : "+listXe.size());
    }
    public void search(){
        String bsx ;
        bsx = scan.nextLine();
        for (int i = 0; i < listXe.size(); i++) {
            if (listXe.get(i).getBienso().equalsIgnoreCase(bsx)) {
                listXe.get(i).hienthi();
            }
        }
    }
}



/*
 * 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 hanoi.xemay;
import java.util.Scanner;
import xeco.info.XeMay;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
/**
 *
 * @author DELL
 */
public class XeMayHaNoi extends XeMay{
    int n;
    Scanner scan = new Scanner(System.in);
    ArrayList<XeMay> listXe = new ArrayList<>();

    public XeMayHaNoi(int n, String bienso, String loaixe, String mauxe, float giatien) {
        super(bienso, loaixe, mauxe, giatien);
        this.n = n;
    }

    public XeMayHaNoi() {
    }
    
    
    
    @Override
    public void nhap(){
        System.out.println("Nhap so xe may can quan ly (Ha Noi) : ");
        n=Integer.parseInt(scan.nextLine());
        for (int i = 0; i < n; i++) {
            XeMay xemay = new XeMay();
            xemay.nhap();
            listXe.add(xemay);
          
        }
    }
    @Override
    public void hienthi(){
        System.out.println("Danh sach xe may tai Ha Noi : \n");
        for (int i = 0; i < listXe.size(); i++) {
            listXe.get(i).hienthi();
        }
    }
    public void sort(){
        Collections.sort(listXe, new Comparator<XeMay>() {
            @Override
            public int compare(XeMay o1, XeMay o2) {
                if(o2.getBienso().equalsIgnoreCase(o2.getBienso())){
                    return 1;
                }return -1;
            }
            
            
        });
        hienthi();
    }
    
    public void thongkeSL(){
        System.out.println("So luong xe quan ly tai Ha  : "+listXe.size());
    }
    public void search(){
        String bsx ;
        bsx = scan.nextLine();
        for (int i = 0; i < listXe.size(); i++) {
            if (listXe.get(i).getBienso().equalsIgnoreCase(bsx)) {
                listXe.get(i).hienthi();
            }
        }
    }
}



/*
 * 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 xeco.info;

import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class XeMay implements IXe {

    String bienso;

    String loaixe;

    String mauxe;

    float giatien;

    public XeMay() {
    }

    public XeMay(String bienso, String loaixe, String mauxe, float giatien) {
        this.bienso = bienso;
        this.loaixe = loaixe;
        this.mauxe = mauxe;
        this.giatien = giatien;
    }

    public String getBienso() {
        return bienso;
    }

    public void setBienso(String bienso) {
        this.bienso = bienso;
    }

    public String getLoaixe() {
        return loaixe;
    }

    public void setLoaixe(String loaixe) {
        this.loaixe = loaixe;
    }

    public String getMauxe() {
        return mauxe;
    }

    public void setMauxe(String mauxe) {
        this.mauxe = mauxe;
    }

    public float getGiatien() {
        return giatien;
    }

    public void setGiatien(float giatien) {
        this.giatien = giatien;
    }

    @Override
    public void nhap() {
        Scanner scan = new Scanner(System.in);
        System.out.println("Bien so : ");
        bienso = scan.nextLine();
        
        System.out.println("Loai xe : ");
        loaixe = scan.nextLine();

        System.out.println("Mau xe : ");
        mauxe = scan.nextLine();

        System.out.println("Gia tien : ");
        giatien = Float.parseFloat(scan.nextLine());

    }

    @Override
    public void hienthi() {
          toString();
    }

    @Override
    public String toString() {
        return "XeMay{" + "bienso=" + bienso + ", loaixe=" + loaixe + ", mauxe=" + mauxe + ", giatien=" + giatien + '}';
    }
    
}



/*
 * 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 xeco.info;

/**
 *
 * @author DELL
 */
public interface IXe {

    public void nhap();

    public void hienthi();
    
}