Advertisement
Guest User

Untitled

a guest
May 21st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package sach;
  7.  
  8. import java.util.Scanner;
  9.  
  10. /**
  11. *
  12. * @author ASUS
  13. */
  14. public class Docgia {
  15.  
  16. int madocgia;
  17. String ten;
  18. String diachi;
  19.  
  20. public Docgia(int madocgia, String ten, String diachi) {
  21. this.madocgia = madocgia;
  22. this.ten = ten;
  23. this.diachi = diachi;
  24. }
  25.  
  26. public Docgia() {
  27. madocgia = 1;
  28. ten = "";
  29. diachi = "";
  30. }
  31.  
  32. //getters
  33. public int getMadocgia() {
  34. return madocgia;
  35. }
  36.  
  37. public String getTen() {
  38. return ten;
  39. }
  40.  
  41. public String getDiachi() {
  42. return diachi;
  43. }
  44.  
  45. //setters
  46. public void setMadocgia(int madocgia) {
  47. this.madocgia = madocgia;
  48. }
  49.  
  50. public void setTen(String ten) {
  51. if (!ten.equals("")) {
  52. this.ten = ten;
  53. } else {
  54. System.out.println("\nKhong dung yeu cau.\n");
  55. }
  56. }
  57.  
  58. public void setDiachi(String diachi) {
  59. if (!diachi.equals("")) {
  60. this.diachi = diachi;
  61. } else {
  62. System.out.println("\nKhong dung yeu cau.\n");
  63. }
  64. }
  65.  
  66. void nhapDocgia() {
  67. Scanner sc = new Scanner(System.in);
  68. System.out.println("Nhap ma doc gia: ");
  69. madocgia = sc.nextInt();
  70. sc = new Scanner(System.in);
  71. System.out.println("Nhap ten doc gia: ");
  72. ten = sc.nextLine();
  73. sc = new Scanner(System.in);
  74. System.out.println("Nhap dia chi doc gia: ");
  75. diachi = sc.nextLine();
  76. }
  77.  
  78. void xuatDocgia() {
  79. System.out.println("Ma doc gia: " + madocgia);
  80. System.out.println("Ten doc gia: " + ten);
  81. System.out.println("Dia chi doc gia: " + diachi);
  82. }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement