Facebook
From da, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 292
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. import javax.swing.JOptionPane;
  6.  
  7. class Postac {
  8.         String imie;
  9.         int moc;
  10.         int x;
  11.         int y;
  12.  
  13.         public Postac(String Imie, int Moc, int X, int Y) {
  14.                 this.imie = Imie;
  15.                 this.moc = Moc;
  16.                 this.x = X;
  17.                 this.y = Y;
  18.  
  19.         };
  20.  
  21.         public void setPozycja(int x, int y) {
  22.                 this.x = x;
  23.                 this.y = y;
  24.         }
  25.  
  26.         int getX() {
  27.                 return x;
  28.         }
  29.  
  30.         int getY() {
  31.                 return y;
  32.         }
  33.  
  34. }
  35.  
  36. class Hero extends Postac {
  37.  
  38.         public Hero(String Imie, int Moc, int X, int Y) {
  39.                 super(Imie, Moc, X, Y);
  40.         }
  41.  
  42.         public void ruch(String Ruch) {
  43.  
  44.                 if (Ruch == "G") {
  45.                         this.x = x - 1;
  46.                 }
  47.                 if (Ruch == "D") {
  48.                         this.x = x + 1;
  49.                 }
  50.                 if (Ruch == "P") {
  51.  
  52.                         this.y = y + 1;
  53.                 }
  54.                 if (Ruch == "L") {
  55.                         this.y = y - 1;
  56.                 }
  57.  
  58.         }
  59. }
  60.  
  61. class Enemy extends Postac {
  62.         public Enemy(String Imie, int Moc, int X, int Y) {
  63.                 super(Imie, Moc, X, Y);
  64.         }
  65. }
  66.  
  67. class Mapa {
  68.         final int szerokoscPlanszy = 20;
  69.         final int wysokoscPlanszy = 20;
  70.         char[][] map = new char[szerokoscPlanszy][wysokoscPlanszy];
  71.         boolean jestok = true;
  72.  
  73.         public void sprawdz(int x, int y) {
  74.                 if (x < 0 || x > this.szerokoscPlanszy || y < 0 || y > this.wysokoscPlanszy) {
  75.                         System.out.print("\n GAME OVER ");
  76.                         this.jestok = false;
  77.                 }
  78.  
  79.         }
  80.  
  81.         void pokaz(int xx, int yy) {
  82.                 for (int a = 0; a < this.szerokoscPlanszy; a++) {
  83.                         System.out.print(a);
  84.                         for (int b = 0; b < this.wysokoscPlanszy; b++) {
  85.                                 if (a == 0)
  86.                                         System.out.print(b + " ");
  87.                                 else if (a == xx && b == yy) {
  88.                                         System.out.print("G" + " ");
  89.                                 } else {
  90.                                         System.out.print(
  91.                                                         // map[a][b] +
  92.                                                         " ");
  93.                                 }
  94.                         }
  95.                         System.out.print("\n");
  96.                 }
  97.         }
  98. }
  99.  
  100. public class Main {
  101.         public static void main(String[] args) {
  102.  
  103.                 Hero bohater = new Hero("Michal", 20, 10, 10);
  104.                 Mapa map = new Mapa();
  105.  
  106.                 Scanner input = new Scanner(System.in);
  107.  
  108.                 map.pokaz(bohater.getX(), bohater.getY());
  109.  
  110.                 // if (map.jestok = false) {
  111.                 // System.out.print("KONIEC GRY");
  112.                 // } else {
  113.                 // System.out.print("Wprowadz litere ruchu(G,D,L,P) i enter: ");
  114.                 //
  115.                 // // String steruj= input.nextLine();
  116.                 //
  117.                 //// bohater.ruch("D");
  118.                 //
  119.                 // map.pokaz(bohater.getX(), bohater.getY());
  120.                 //
  121.                 // }
  122.  
  123.         }
  124. }