By GokiSoft.com| 19:27 19/04/2024|
Java Basic

Java basic- Overview - phân tích thiết kế lớp đối tượng trong java

Các bài tập dưới đây yêu cầu bạn phải tự biết khai báo các thuộc tính cho lớp, cài đặt đầy đủ 2 constructor, các phương thức set/get, 2 hàm input() và display() để nhập và hiển thị các thuộc tính trong lớp đó.

Sau khi đã cài đặt lớp xong thì cài đặt thêm class Test để khởi tạo đối tượng của lớp (có thể tạo mảng đối tượng và ít nhất cũng phải tạo 2 đối tượng để khởi tạo bằng constructor có tham số và constructor không có tham số).

Bài 1.

Cài đặt lớp để mô tả về đối tượng Computer .

Bài 2.

Cài đặt lớp để mô tả đối tượng House

Bài 3.

Cài đặt lớp để mô tả đối tượng Car

Bài 4.

Cài đặt lớp để mô tả đối tượng Mark (điểm thi)

Bài 5.

Cài đặt lớp để mô tả đối tượng Country

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

5

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

vuong huu phu [T2008A]
vuong huu phu

2021-02-23 03:17:01


bai 1


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

/**
 *
 * @author Admin
 */
public class Test_computer {
    public static void main(String[] args) {
    Computer pc1 = new Computer();
    pc1.Mhap();
    pc1.Hien_thi();
    Computer pc2 = new Computer("CPU Intel Core i9-10940X","RAM Desktop Gskill Trident Z Neo","SSD","Mainboard Asus Z11PA-D8");
}}



vuong huu phu [T2008A]
vuong huu phu

2021-02-23 03:16:09




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

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class Computer {

    String Cpu, Ram, O_cung, Mainboard;

    Scanner scan = new Scanner(System.in);

    public Computer() {
    }

    public Computer(String Cpu, String Ram, String O_cung, String Mainboard) {
        this.Cpu = Cpu;
        this.Ram = Ram;
        this.O_cung = O_cung;
        this.Mainboard = Mainboard;
        System.out.println(Cpu + " , " + Ram + " , " + O_cung + " , " + Mainboard + ":");
    }

    public String getCpu() {
        return Cpu;
    }

    public void setCpu(String Cpu) {
        this.Cpu = Cpu;
    }

    public String getRam() {
        return Ram;
    }

    public void setRam(String Ram) {
        this.Ram = Ram;
    }

    public String getO_cung() {
        return O_cung;
    }

    public void setO_cung(String O_cung) {
        this.O_cung = O_cung;
    }

    public String getMainboard() {
        return Mainboard;
    }

    public void setMainboard(String Mainboard) {
        this.Mainboard = Mainboard;
    }

    public Scanner getScan() {
        return scan;
    }

    public void setScan(Scanner scan) {
        this.scan = scan;
    }

    public void Mhap() {
        System.out.println("Nhap ten CPU: ");
        Cpu = scan.nextLine();
        System.out.println("Nhap ten RAM: ");
        Ram = scan.nextLine();
        System.out.println("Nhap ten O cung: ");
        O_cung = scan.nextLine();
        System.out.println("Nhap ten Mainboard: ");
        Mainboard = scan.nextLine();
    }

    public void Hien_thi() {
        System.out.println("CPU: " + Cpu + " , RAM: " + Ram + " , O cung: " + O_cung + " , Mainboard: " + Mainboard + ":");
    }
}



nguyễn Sử [T2008A]
nguyễn Sử

2021-02-22 14:47:43




import java.util.Scanner;

/*
 * 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.
 */
/**
 *
 * @author WIN10
 */
public class computer {

    public computer() {
    }
    private String id;
    private String computername;
    private int yearsx;
    private float price;

    public computer(String id, String computername, int yearsx, float price) {
        this.id = id;
        this.computername = computername;
        this.yearsx = yearsx;
        this.price = price;
    }

    public String getId() {
        return id;
    }

    public String getComputername() {
        return computername;
    }

    public int getYearsx() {
        return yearsx;
    }

    public float getPrice() {
        return price;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setComputername(String computername) {
        this.computername = computername;
    }

    public void setYearsx(int yearsx) {
        this.yearsx = yearsx;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public void input() {

        Scanner scan = new Scanner(System.in);

        System.out.println("nhap ten pc");
        computername = scan.nextLine();

        System.out.println("nhap nam san xuat");
        yearsx = scan.nextInt();

        System.out.println("nhap gia");
        price = scan.nextInt();

    }
@Override
    public String toString() {
        return "computer{" + "tenpcy=" + computername + ", nam san xuat=" + yearsx + ", giá=" + price + '}';
    }
    
    
    public void display() {
        System.out.println(toString());
    }    

}



cuonglee [C1907L]
cuonglee

2020-04-27 04:09:57



/*
 * 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 overview.phantichthietke;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class Car {
    String hangXe,mauXe;
    float giaTien;
    int soBanh;

    public Car() {
    }

    public Car(String hangXe, String mauXe, float giaTien, int soBanh) {
        this.hangXe = hangXe;
        this.mauXe = mauXe;
        this.giaTien = giaTien;
        this.soBanh = soBanh;
    }

    public String getHangXe() {
        return hangXe;
    }

    public void setHangXe(String hangXe) {
        this.hangXe = hangXe;
    }

    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 int getSoBanh() {
        return soBanh;
    }

    public void setSoBanh(int soBanh) {
        this.soBanh = soBanh;
    }
    
    public void input() {
        Scanner add = new Scanner(System.in);
        System.out.println("nhap du lieu xe: ");
        System.out.println("nhap ten hang xe: ");
        hangXe = add.next();
        System.out.println("nhap mau xe: ");
        mauXe = add.next();
        System.out.println("nhap so banh xe: ");
        soBanh = add.nextInt();
        System.out.println("nhap gia tien: ");
        giaTien = add.nextFloat();
        
    }

    @Override
    public String toString() {
        return "Car{" + "hangXe=" + hangXe + ", mauXe=" + mauXe + ", giaTien=" + giaTien + ", soBanh=" + soBanh + '}';
    }
    
    
    public void display() {
        System.out.println(toString());
    }
    
}

/*
 * 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 overview.phantichthietke;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class Country {
    String address,ten;
    int soDanCu;

    public Country() {
    }

    public Country(String address, String ten, int soDanCu) {
        this.address = address;
        this.ten = ten;
        this.soDanCu = soDanCu;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getTen() {
        return ten;
    }

    public void setTen(String ten) {
        this.ten = ten;
    }

    public int getSoDanCu() {
        return soDanCu;
    }

    public void setSoDanCu(int soDanCu) {
        this.soDanCu = soDanCu;
    }
    
    public void input(){
        Scanner add = new Scanner(System.in);
        System.out.println("nhap du lieu country");
        System.out.println("nhap ten: ");
        ten = add.next();
        System.out.println("nhap dia chi: ");
        address = add.next();
        System.out.println("nhap so dan cu: ");
        soDanCu = add.nextInt();
    }

    @Override
    public String toString() {
        return "Country{" + "address=" + address + ", ten=" + ten + ", soDanCu=" + soDanCu + '}';
    }
    
    public void display(){
        System.out.println(toString());
    }
}
/*
 * 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 overview.phantichthietke;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class Hourse {
    String color,gioiTinh;
    int soChan;
    float canNang;

    public Hourse() {
    }

    public Hourse(String color, String gioiTinh, int soChan, float canNang) {
        this.color = color;
        this.gioiTinh = gioiTinh;
        this.soChan = soChan;
        this.canNang = canNang;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getGioiTinh() {
        return gioiTinh;
    }

    public void setGioiTinh(String gioiTinh) {
        this.gioiTinh = gioiTinh;
    }

    public int getSoChan() {
        return soChan;
    }

    public void setSoChan(int soChan) {
        this.soChan = soChan;
    }

    public float getCanNang() {
        return canNang;
    }

    public void setCanNang(float canNang) {
        this.canNang = canNang;
    }
    
    public void input() {
        Scanner add = new Scanner(System.in);
        System.out.println("nhap du lieu: ");
        System.out.println("nhap mau: ");
        color = add.next();
        System.out.println("nhap gioi tinh: ");
        gioiTinh = add.next();
        System.out.println("nhap so chan: ");
        soChan = add.nextInt();
        System.out.println("nhap can nang: ");
        canNang = add.nextFloat();
    }

    @Override
    public String toString() {
        return "Hourse{" + "color=" + color + ", gioiTinh=" + gioiTinh + ", soChan=" + soChan + ", canNang=" + canNang + '}';
    }
    
    public void display() {
        System.out.println(toString());
    }
}

/*
 * 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 overview.phantichthietke;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class Mark {
    String tenHocSinh,tenMonHoc;
    float giaTri;

    public Mark() {
    }
    
     
    public Mark(String tenHocSinh, String tenMonHoc, float giaTri) {
        this.tenHocSinh = tenHocSinh;
        this.tenMonHoc = tenMonHoc;
        this.giaTri = giaTri;
    }

    public String getTenHocSinh() {
        return tenHocSinh;
    }

    public void setTenHocSinh(String tenHocSinh) {
        this.tenHocSinh = tenHocSinh;
    }

    public String getTenMonHoc() {
        return tenMonHoc;
    }

    public void setTenMonHoc(String tenMonHoc) {
        this.tenMonHoc = tenMonHoc;
    }

    public float getGiaTri() {
        return giaTri;
    }

    public void setGiaTri(float giaTri) {
        this.giaTri = giaTri;
    }
    
    public void input() {
        Scanner add = new Scanner(System.in);
        System.out.println("nhap du lieu diem: ");
        System.out.println("nhap ten hoc sinh: ");
        tenHocSinh = add.next();
        System.out.println("nhap ten mon hoc: ");
        tenMonHoc = add.next();
        System.out.println("nhap gia tri: ");
        giaTri = add.nextFloat();
    }

    @Override
    public String toString() {
        return "Mark{" + "tenHocSinh=" + tenHocSinh + ", tenMonHoc=" + tenMonHoc + ", giaTri=" + giaTri + '}';
    }
    
    
    public void display(){
        System.out.println(toString());
    }
    
}

/*
 * 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 overview.phantichthietke;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class computer {
    String tenHangMay;
    int chuot,banPhim;

    public computer() {
    }

    public computer(String tenHangMay, int chuot, int banPhim) {
        this.tenHangMay = tenHangMay;
        this.chuot = chuot;
        this.banPhim = banPhim;
    }

    public String getTenHangMay() {
        return tenHangMay;
    }

    public void setTenHangMay(String tenHangMay) {
        this.tenHangMay = tenHangMay;
    }

    public int getChuot() {
        return chuot;
    }

    public void setChuot(int chuot) {
        this.chuot = chuot;
    }

    public int getBanPhim() {
        return banPhim;
    }

    public void setBanPhim(int banPhim) {
        this.banPhim = banPhim;
    }

   
    
    public void input() {
        Scanner add = new Scanner(System.in);
        System.out.println("Nhap du lieu: ");
        System.out.println("nhap ten hang may: ");
        tenHangMay = add.next();
        System.out.println("nhap so luong chuot: ");
        chuot = add.nextInt();
        System.out.println("nhap so luong ban phim: ");
        banPhim = add.nextInt();
    }

    @Override
    public String toString() {
        return "computer{" + "tenHangMay=" + tenHangMay + ", chuot=" + chuot + ", banPhim=" + banPhim + '}';
    }
    
    
    public void display() {
        System.out.println(toString());
    }
}

/*
 * 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 overview.phantichthietke;

import java.util.ArrayList;

/**
 *
 * @author Admin
 */
public class Test {
    public static void main(String[] args) {
        ArrayList<computer> list = new ArrayList();
       
        computer cpt1 = new computer();
        computer cpt2 = new computer("Dell",1,2);
        
        cpt1.input();
        cpt1.display();
        cpt2.display();
        
        Hourse h1 = new Hourse();
        Hourse h2 = new Hourse("nau","duc",4,30.5f);
        
        h1.input();
        h1.display();
        h2.display();
      
        Car c1 = new Car();
        Car c2 = new Car("bmw","xanh",9.5f,4);
        
        c1.input();
        c1.display();
        c2.display();
        
        Mark m1 = new Mark();
        Mark m2 = new Mark("Ling","Anh",6.5f);
        
        m1.input();
        m1.display();
        m2.display();
        
        Country cou1 = new Country();
        Country cou2 = new Country("hanoi","hotay",15000);
        
        cou1.input();
        cou1.display();
        cou2.display();
    }
}




Hoàng Quang Huy [C1907L]
Hoàng Quang Huy

2020-03-22 10:20:19



// Class Computer
package Lesson5;

import java.util.Scanner;

public class Computer {

    private String name, brand, ram, cpu;
    private double price, weight;

    public Computer() {
    }

    public Computer(String name, String brand, String ram, String cpu, double price, double weight) {
        this.name = name;
        this.brand = brand;
        this.ram = ram;
        this.cpu = cpu;
        this.price = price;
        this.weight = weight;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getRam() {
        return ram;
    }

    public void setRam(String ram) {
        this.ram = ram;
    }

    public String getCpu() {
        return cpu;
    }

    public void setCpu(String cpu) {
        this.cpu = cpu;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Input Name: ");
        name = input.nextLine();
        System.out.println("Input Brand: ");
        brand = input.nextLine();
        System.out.println("Input RAM: ");
        ram = input.nextLine();
        System.out.println("Input CPU: ");
        cpu = input.nextLine();
        System.out.println("Input Price: ");
        price = Double.parseDouble(input.nextLine());
        System.out.println("Input Weight: ");
        weight = Double.parseDouble(input.nextLine());
    }

    public void output() {
        System.out.println("Name: " + name);
        System.out.println("Brand: " + brand);
        System.out.println("RAM: " + ram);
        System.out.println("CPU: " + cpu);
        System.out.println("Price: " + price);
        System.out.println("Weight: " + weight);
    }
}
----------------------------------------------------------------------------
//Class House

package Lesson5;

import java.util.Scanner;

public class House {
    private String address,owner;
    private float area;
    private int storey;

    public House() {
    }

    public House(String address, String owner, float area, int storey) {
        this.address = address;
        this.owner = owner;
        this.area = area;
        this.storey = storey;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public float getArea() {
        return area;
    }

    public void setArea(float area) {
        this.area = area;
    }

    public int getStorey() {
        return storey;
    }

    public void setStorey(int storey) {
        this.storey = storey;
    }
    
    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Input Address: ");
        address = input.nextLine();
        System.out.println("Input Owner: ");
        owner = input.nextLine();
        System.out.println("Input Area: ");
        area = Float.parseFloat(input.nextLine());
        System.out.println("Input Storeys: ");
        storey = Integer.parseInt(input.nextLine());
    }

    public void output() {
        System.out.println("Address: " + address);
        System.out.println("Owner: " + owner);
        System.out.println("Area: " + area);
        System.out.println("Storeys: " + storey);
    }
}
---------------------------------------------------------------------------
//Class Car
package Lesson5;

import java.util.Scanner;

public class Car {

    private String name, color, brand;
    private double price;

    public Car() {
    }

    public Car(String name, String color, String brand, double price) {
        this.name = name;
        this.color = color;
        this.brand = brand;
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Input Name: ");
        name = input.nextLine();
        System.out.println("Input Color: ");
        color = input.nextLine();
        System.out.println("Input Brand: ");
        brand = input.nextLine();
        System.out.println("Input Price: ");
        price = Double.parseDouble(input.nextLine());
    }

    public void ouput() {
        System.out.println("Name: " + name);
        System.out.println("Color: " + color);
        System.out.println("Brand: " + brand);
        System.out.println("Price: " + price);
    }
}
-----------------------------------------------------------------------------
//Class Mark

package Lesson5;

import java.util.Scanner;

public class Mark {

    private String studentname, subjectname;
    private float mark;

    public Mark() {
    }

    public Mark(String studentname, String subjectname, float mark) {
        this.studentname = studentname;
        this.subjectname = subjectname;
        this.mark = mark;
    }

    public String getStudentname() {
        return studentname;
    }

    public void setStudentname(String studentname) {
        this.studentname = studentname;
    }

    public String getSubjectname() {
        return subjectname;
    }

    public void setSubjectname(String subjectname) {
        this.subjectname = subjectname;
    }

    public float getMark() {
        return mark;
    }

    public void setMark(float mark) {
        this.mark = mark;
    }

    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Input Student Name: ");
        studentname = input.nextLine();
        System.out.println("Input Subject Name: ");
        subjectname = input.nextLine();
        System.out.println("Input Mark: ");
        mark = Float.parseFloat(input.nextLine());
    }

    public void output() {
        System.out.println("Student Name: " + studentname);
        System.out.println("Subject Name: " + subjectname);
        System.out.println("Mark: " + mark);
    }
}
----------------------------------------------------------------------------
// Class Country

package Lesson5;

import java.util.Scanner;

public class Country {
    private String name,language,currency,location;

    public Country() {
    }

    public Country(String name, String language, String currency, String location) {
        this.name = name;
        this.language = language;
        this.currency = currency;
        this.location = location;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }
    
    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Input Country Name: ");
        name = input.nextLine();
        System.out.println("Input Language: ");
        language = input.nextLine();
        System.out.println("Input Currency: ");
        currency = input.nextLine();
        System.out.println("Input Location: ");
        location = input.nextLine();
    }

    public void output() {
        System.out.println("Country Name: " + name);
        System.out.println("Language: " + language);
        System.out.println("Currency: " + currency);
        System.out.println("Location: " + location);
    }
}
---------------------------------------------------------------------------
// Test
package Lesson5;

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

public class Test {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        // test class Computer
        Computer computer1 = new Computer("Thinkpad","Lenovo","8GB","Intel Core i5",1000,1.3);
        Computer computer2 = new Computer();
        computer2.input();
        computer1.output();
        computer2.output();
        // test class House
        House house1 = new House("Hà Nôi","Nguyễn Văn A",150,4);
        House house2 = new House();
        ArrayList<House> houses = new ArrayList<>();
        houses.add(house1);
        System.out.println("Nhập số nhà: ");
        int n = Integer.parseInt(input.nextLine());
        for (int i = 0; i < n ; i++) {
            House house = new House();
            house.input();
            houses.add(house);
        }
        for (int i = 0; i < houses.size(); i++) {
            houses.get(i).output();
            System.out.println("-----------------");
        }
        // test class Car
        Car car1 = new Car("Car 1","Black","BMW",2000000000);
        Car car2 = new Car();
        car2.input();
        car1.ouput();
        car2.ouput();
        // test class Mark
        Mark mark1 = new Mark("Nguyễn Thị A","Toán", 9);
        Mark mark2 = new Mark();
        mark2.input();
        mark1.output();
        mark2.output();
        // test class Country
        Country country1 = new Country("Việt Nam","Vietnamese","vietnamdong","SEA");
        Country country2 = new Country();
        country2.input();
        country1.output();
        country2.output();
    }
}







trung [C1907L]
trung

2020-03-22 10:13:38



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

import java.util.Scanner;

/**
 *
 * @author prdox
 */
public class Computer {
    String Name,Brand;

    public Computer() {
    }

    public Computer(String Name, String Brand) {
        this.Name = Name;
        this.Brand = Brand;
    }

    public String getName() {
        return Name;
    }

    public String getBrand() {
        return Brand;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public void setBrand(String Brand) {
        this.Brand = Brand;
    }
    
    public void input(){
        Scanner input = new Scanner(System.in);
        System.out.println("Computer name:");
        Name = input.nextLine();
        System.out.println("Brand name:");
        Brand = input.nextLine();
    }
    
    public void output(){
        System.out.println(toString());
    }

    @Override
    public String toString() {
        return "Computer{" + "Name=" + Name + ", Brand=" + Brand + '}';
    }
    
}



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

import java.util.Scanner;

/**
 *
 * @author prdox
 */
public class House {
    String Address;
    int Area;

    public House() {
    }

    public House(String Address, int Area) {
        this.Address = Address;
        this.Area = Area;
    }
    
    public void input(){
        Scanner input = new Scanner(System.in);
        System.out.println("Address:");
        Address = input.nextLine();
        System.out.println("Area:");
        Area = Integer.parseInt(input.nextLine());
    }

    @Override
    public String toString() {
        return "House{" + "Address=" + Address + ", Area=" + Area + '}';
    }
    
    public void output(){
        System.out.println(toString());
    }

    public String getAddress() {
        return Address;
    }

    public int getArea() {
        return Area;
    }

    public void setAddress(String Address) {
        this.Address = Address;
    }

    public void setArea(int Area) {
        this.Area = Area;
    }
    
    
}



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

import java.util.Scanner;

/**
 *
 * @author prdox
 */
public class Car {
    String Name,Brand;
    
    public Car() {
    }

    public Car(String Name, String Brand) {
        this.Name = Name;
        this.Brand = Brand;
    }

    public String getName() {
        return Name;
    }

    public String getBrand() {
        return Brand;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public void setBrand(String Brand) {
        this.Brand = Brand;
    }
    
    public void input(){
        Scanner input = new Scanner(System.in);
        System.out.println("Car name:");
        Name = input.nextLine();
        System.out.println("Brand name:");
        Brand = input.nextLine();
    }
    
    public void output(){
        System.out.println(toString());
    }

    @Override
    public String toString() {
        return "Car{" + "Name=" + Name + ", Brand=" + Brand + '}';
    }
}



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

import java.util.Scanner;

/**
 *
 * @author prdox
 */
public class Mark {
    String Name;
    float Value;

    public Mark() {
    }

    public Mark(String Name, float Value) {
        this.Name = Name;
        this.Value = Value;
    }
    
    public void input(){
        Scanner input = new Scanner(System.in);
        System.out.println("Student name");
        this.Name = input.nextLine();
        System.out.println("Mark: ");
        this.Value = Float.parseFloat(input.nextLine());
    }

    @Override
    public String toString() {
        return "Mark{" + "Name=" + Name + ", Value=" + Value + '}';
    }
    
    public void output(){
        System.out.println(toString());
    }

    public String getName() {
        return Name;
    }

    public float getValue() {
        return Value;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public void setValue(float Value) {
        this.Value = Value;
    }
    
    
    
    
}



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

import java.util.Scanner;

/**
 *
 * @author prdox
 */
public class Country {
    String Name,Language;
    public Country() {
    }

    public Country(String Name, String Language) {
        this.Name = Name;
        this.Language = Language;
    }

    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public String getLanguage() {
        return Language;
    }

    public void setLanguage(String Language) {
        this.Language = Language;
    }
    
    
    public void input(){
        Scanner input = new Scanner(System.in);
        System.out.println("Country name:");
        Name = input.nextLine();
        System.out.println("Language:");
        Language = input.nextLine();
    }
    
    public void output(){
        System.out.println(toString());
    }

    @Override
    public String toString() {
        return "Country{" + "Name=" + Name + ", Language=" + Language + '}';
    }
}



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

/**
 *
 * @author prdox
 */
public class Test {
    public static void main(String[] args) {
        Computer computer1 = new Computer();
        Computer computer2 = new Computer("asus_1","asus");
        computer1.input();
        computer1.output();
        computer2.output();
        
        House house1 = new House();
        House house2 = new House("abc street xyz",23);
        house1.input();
        house1.output();
        house2.output();
        
        Car car1 = new Car();
        Car car2 = new Car("abcxyz","Ford");
        car1.input();
        car1.output();
        car2.output();
        
        Mark mark1 = new Mark();
        Mark mark2 = new Mark("Nguyen Van A", 9);
        mark1.input();
        mark1.output();
        mark2.output();
        
        Country country1 = new Country();
        Country country2 = new Country("East Laos", "Vietnamese");
        country1.input();
        country1.output();
        country2.output();
        
        
    }
}



Nguyễn Hoàng Anh [C1907L]
Nguyễn Hoàng Anh

2020-03-21 12:32:56



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

/**
 *
 * @author Redmibook 14
 */
public class Computer {

    String monitor;
    String keyboard;
    String mouse;
    String Case;
    String main;
    String cpu;
    String fan;
    String ram;
    String rom;
    String gpu;

    Computer() {
    }

    Computer(String monitor, String keyboard, String mouse,
            String Case, String main, String cpu, String fan, String ram, String rom, String gpu) {
        this.monitor = monitor;
        this.keyboard = keyboard;
        this.mouse = mouse;
        this.Case = Case;
        this.cpu = cpu;
        this.main = main;
        this.fan = fan;
        this.gpu = gpu;
        this.ram = ram;
        this.rom = rom;
    }

    public void input(String monitor, String keyboard, String mouse,
            String Case, String main, String cpu, String fan, String ram, String rom, String gpu) {
        this.monitor = monitor;
        this.keyboard = keyboard;
        this.mouse = mouse;
        this.Case = Case;
        this.cpu = cpu;
        this.main = main;
        this.fan = fan;
        this.gpu = gpu;

    }

    public void display() {
        System.out.println("Monitor : " + monitor);
        System.out.println("Keyboard : " + keyboard);
        System.out.println("Mouse : " + mouse);
        System.out.println("Case : " + Case);
        System.out.println("CPU : " + cpu);
        System.out.println("Main : " + main);
        System.out.println("Fan : " + fan);
        System.out.println("GPU : " + gpu);
    }

    public String getMonitor() {
        return monitor;
    }

    public String getKeyboard() {
        return keyboard;
    }

    public void setMonitor(String monitor) {
        this.monitor = monitor;
    }

    public void setKeyboard(String keyboard) {
        this.keyboard = keyboard;
    }

    public void setMouse(String mouse) {
        this.mouse = mouse;
    }

    public void setCase(String Case) {
        this.Case = Case;
    }

    public void setMain(String main) {
        this.main = main;
    }

    public void setCpu(String cpu) {
        this.cpu = cpu;
    }

    public void setFan(String fan) {
        this.fan = fan;
    }

    public void setRam(String ram) {
        this.ram = ram;
    }

    public void setRom(String rom) {
        this.rom = rom;
    }

    public void setGpu(String gpu) {
        this.gpu = gpu;
    }

    public String getMouse() {
        return mouse;
    }

    public String getCase() {
        return Case;
    }

    public String getMain() {
        return main;
    }

    public String getCpu() {
        return cpu;
    }

    public String getFan() {
        return fan;
    }

    public String getRam() {
        return ram;
    }

    public String getRom() {
        return rom;
    }

    public String getGpu() {
        return gpu;
    }
    
}



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

/**
 *
 * @author Redmibook 14
 */
public class test {

    public static void main(String[] args) {
        Computer computer = new Computer("SamSung", "Razer-Z02", "Sony-T1", "Glass-2",
                "Intel 8100U", "Gigabyte-G81", "Razor-led2", "GTX-1050ti", "Samsung-h2", "SSD-Samsung");
        Computer computer2 = new Computer();
        computer2.input("SamSung-t2", "Razer-Z12", "Sony-H2", "Glass-3",
                "Intel 8250U", "Gigabyte-X2t", "Razor-led05", "GTX-2050ti", "Samsung-h01", "SSD-SamsungZ");
        computer.display();
        computer2.display();
    }
}



Ngô Quang Huy [C1907L]
Ngô Quang Huy

2020-03-21 03:34:22



package March21;

import java.util.Scanner;

public class Computer {
    String Name;
    String Brand;

    public Computer() {
    }

    public Computer(String Name, String Brand) {
        this.Name = Name;
        this.Brand = Brand;
    }

    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public String getBrand() {
        return Brand;
    }

    public void setBrand(String Brand) {
        this.Brand = Brand;
    }
    
    public void inputCom(){
        Scanner input = new Scanner(System.in);
        System.out.println("Insert Computer Name:");
        Name = input.nextLine();
        System.out.println("Insert Computer Brand:");
        Brand = input.nextLine();
    }
    
    public void outputCom(){
        System.out.println("Computer Name:"+Name);
        System.out.println("Computer Brand:"+Brand);
    }
}



package March21;

import java.util.Scanner;

public class House {
    String Address;
    int Floor;

    public House() {
    }

    public House(String Address, int Floor) {
        this.Address = Address;
        this.Floor = Floor;
    }

    public String getAddress() {
        return Address;
    }

    public void setAddress(String Address) {
        this.Address = Address;
    }

    public int getFloor() {
        return Floor;
    }

    public void setFloor(int Floor) {
        this.Floor = Floor;
    }
    
    
    public void inputHou(){
        Scanner input = new Scanner(System.in);
        System.out.println("Insert House Address:");
        Address = input.nextLine();
        System.out.println("Insert House's Floor Number:");
        Floor = Integer.parseInt(input.nextLine());
    }
    public void outputHou(){
        System.out.println("House Address:"+Address);
        System.out.println("House Floor Number:"+Floor);
    }
}



package March21;

import java.util.Scanner;

public class Car {
    String Name;
    String Brand;

    public Car() {
    }

    public Car(String Name, String Brand) {
        this.Name = Name;
        this.Brand = Brand;
    }

    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public String getBrand() {
        return Brand;
    }

    public void setBrand(String Brand) {
        this.Brand = Brand;
    }
    
    
    public void inputcar(){
        Scanner input = new Scanner(System.in);
        System.out.println("Insert Car Name:");
        Name = input.nextLine();
        System.out.println("Insert Car Brand:");
        Brand = input.nextLine();
    }
    
    public void outputCar(){
        System.out.println("Car Name:"+Name);
        System.out.println("Car Brand:"+Brand);
    }
}



package March21;

import java.util.Scanner;

public class Mark {
    String Name;
    int Grade;

    public Mark() {
    }

    public Mark(String Name, int Grade) {
        this.Name = Name;
        this.Grade = Grade;
    }

    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public int getGrade() {
        return Grade;
    }

    public void setGrade(int Grade) {
        this.Grade = Grade;
    }
    
    
    public void inputGrd(){
        Scanner input = new Scanner(System.in);
        System.out.println("Insert Student Name:");
        Name = input.nextLine();
        System.out.println("Insert Student Mark:");
        Grade = Integer.parseInt(input.nextLine());
    }
    
    public void outputGrd(){
        System.out.println("Student Name:"+Name);
        System.out.println("Student Mark:"+Grade);
    }
}



package March21;

import java.util.Scanner;

public class Country {
    String Name;
    String Language;

    public Country() {
    }

    public Country(String Name, String Language) {
        this.Name = Name;
        this.Language = Language;
    }

    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public String getLanguage() {
        return Language;
    }

    public void setLanguage(String Language) {
        this.Language = Language;
    }
    
    
    public void inputCtr(){
        Scanner input = new Scanner(System.in);
        System.out.println("Insert Country Name:");
        Name = input.nextLine();
        System.out.println("Insert Country Language:");
        Language = input.nextLine();
    }
    
    public void outputCtr(){
        System.out.println("Country Name:"+Name);
        System.out.println("Country Language:"+Language);
    }
}



package March21;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Computer Com = new Computer();
        Com.inputCom();
        House Hou= new House();
        Hou.inputHou();
        Car Cr= new Car("Special Edition","Volkswagen");
        Mark Grd= new Mark("Mr B",6);
        Country Cnt= new Country("USA","English");
        
        Com.outputCom();
        Hou.outputHou();
        Cr.outputCar();
        Grd.outputGrd();
        Cnt.outputCtr();
    }
}



Vũ Việt Đức [C1907L]
Vũ Việt Đức

2020-03-20 17:11:19




package homework1;

public class Test {
    public static void main(String[] args){
        Car car = new Car();
        Computer computer = new Computer();
        House house = new House();
        Mark mark = new Mark("Java", 9.9f);
        Country country = new Country("Viêt Nam", "Châu Á");
        
        car.input();
        computer.input();
        house.input();
        
        car.display();
        computer.display();
        house.display();
        mark.display();
        country.display();
    }    
}



Vũ Việt Đức [C1907L]
Vũ Việt Đức

2020-03-20 17:01:22



/*
 * 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 homework1;
import java.util.Scanner;
// Bai 5: 
public class Country {
    String name, area;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public Country() {
    }

    public Country(String name, String area) {
        this.name = name;
        this.area = area;
    }
    
    public void input(){
        Scanner input = new Scanner(System.in);
        System.out.print("Tên: ");
        name = input.nextLine();
        System.out.print("Khu vực: ");
        area = input.nextLine();
    }
    
    public void display(){
        System.out.print(toString());
    }

    @Override
    public String toString() {
        return "Country{" + "name=" + name + ", area=" + area + '}';
    }
}