Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Hero {
- static class hero{
- int hp, damage;
- //inputan
- public hero(){
- Scanner input=new Scanner(System.in);
- System.out.print("Masukkan Nilai HP hero = ");
- int a=input.nextInt();
- System.out.print("Masukkan Nilai Damage hero = ");
- int b=input.nextInt();
- this.hp=a;
- this.damage=b;
- }
- //cetak
- void cetak(){
- System.out.println("HP adalah "+hp);
- System.out.println("Damage adalah "+damage);
- }
- void up_level(){
- hp=hp+10;
- damage=damage+10;
- System.out.println("HP adalah "+hp);
- System.out.println("Damage adalah "+damage);
- }
- }
- public static void main(String[] args){
- System.out.println("Lesley");
- hero lesley=new hero();
- lesley.cetak();
- lesley.up_level();
- System.out.println("*========*");
- System.out.println("Gatot");
- hero gatot=new hero();
- gatot.cetak();
- gatot.up_level();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement