Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package sach;
- import java.util.Scanner;
- /**
- *
- * @author ASUS
- */
- public class Docgia {
- int madocgia;
- String ten;
- String diachi;
- public Docgia(int madocgia, String ten, String diachi) {
- this.madocgia = madocgia;
- this.ten = ten;
- this.diachi = diachi;
- }
- public Docgia() {
- madocgia = 1;
- ten = "";
- diachi = "";
- }
- //getters
- public int getMadocgia() {
- return madocgia;
- }
- public String getTen() {
- return ten;
- }
- public String getDiachi() {
- return diachi;
- }
- //setters
- public void setMadocgia(int madocgia) {
- this.madocgia = madocgia;
- }
- public void setTen(String ten) {
- if (!ten.equals("")) {
- this.ten = ten;
- } else {
- System.out.println("\nKhong dung yeu cau.\n");
- }
- }
- public void setDiachi(String diachi) {
- if (!diachi.equals("")) {
- this.diachi = diachi;
- } else {
- System.out.println("\nKhong dung yeu cau.\n");
- }
- }
- void nhapDocgia() {
- Scanner sc = new Scanner(System.in);
- System.out.println("Nhap ma doc gia: ");
- madocgia = sc.nextInt();
- sc = new Scanner(System.in);
- System.out.println("Nhap ten doc gia: ");
- ten = sc.nextLine();
- sc = new Scanner(System.in);
- System.out.println("Nhap dia chi doc gia: ");
- diachi = sc.nextLine();
- }
- void xuatDocgia() {
- System.out.println("Ma doc gia: " + madocgia);
- System.out.println("Ten doc gia: " + ten);
- System.out.println("Dia chi doc gia: " + diachi);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement