Mitko_jos

lab9 zadaca 1

Apr 29th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. public class object {
  2. class Objekt {
  3. private String adresa;
  4. private float visina;
  5. private float ploshtina;
  6. public Objekt(String adresa, float visina, float ploshtina){
  7. this.adresa = adresa;
  8. this.visina = visina;
  9. this.ploshtina = ploshtina;
  10. }
  11. public String getAdresa() {
  12. return adresa;
  13. }
  14. public void setAdresa(String adresa) {
  15. this.adresa = adresa;
  16. }
  17. public void setVisina(float visina) {
  18. if(visina > 0)
  19. this.visina = visina;
  20. else
  21. this.visina = 0;
  22. }
  23. public void setPloshtina(float ploshtina){
  24. if(ploshtina > 0)
  25. this.ploshtina = ploshtina;
  26. else
  27. this.ploshtina = 0;
  28. }
  29. public float getVisina(){
  30. return visina;
  31. }
  32. public float getPloshtina(){
  33. return ploshtina;
  34. }
  35. public String toString(){
  36. return "";
  37. }
  38. public void Informacii(){
  39. System.out.println(this.toString());
  40. }
  41. public int Presmetaj(){
  42.  
  43. return 0;
  44. }
  45. }
  46. }
  47.  
  48.  
  49. public class kukja extends object {
  50. private string familija;
  51. public kukja(String adresa, float visina, float ploshtina,String family){
  52. super(adresa,visina,ploshtina);
  53. familija=family;
  54. }
  55. public int Presmetaj(){
  56. return (int) Math.floor((super.getVisina()*super.getPloshtina())/70);
  57. }
  58. public String toString(){
  59. return familija;
  60. }
  61. public void setFamilija(String family){
  62. familija = family;
  63. }
  64. public String getFamilija(){
  65. return familija;
  66. }
  67.  
  68. public class Hotel extends object {
  69. private string sopstvenik;
  70. public Hotel ( String adresa, float visina, float ploshtina,string gazda){
  71. super(adresa,visina,ploshtina);
  72. sopstvenik=gazda;
  73. }
  74. public int Presmetaj(){
  75. return (int) Math.floor((super.getVisina()/3.5));
  76. }
  77. public String toString(){
  78. return sopstvenik;
  79. }
  80. public void setFamilija(String gazda){
  81. sopstvenik = gazda;
  82. }
  83.  
  84. public String getFamilija(){
  85. return sopstvenik;
  86. }
  87.  
  88. }
  89.  
  90. public class lab9 {
  91.  
  92. /**
  93. * @param args the command line arguments
  94. */
  95. public static void main(String[] args) {
  96. Hotel a = new Hotel("Donco", 8, 50, "Donco");
  97. a.Informacii();
  98. System.out.println(a.Presmetaj());
  99.  
  100. kukja h = new kukja("Struga",8,50,"Josifoski");
  101. h.Informacii();
  102. System.out.println(b.Presmetaj());
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment