Note that there are some explanatory texts on larger screens.

plurals
  1. POError: No enclosing instance of type zad_II_1 is accessible
    primarykey
    data
    text
    <p>I'm learning about abstract classes in Java and I have a little problem with this error: No enclosing instance of type zad_II_1 is accessible. Must qualify the allocation with an enclosing instance of type zad_II_1 (e.g. x.new A() where x is an instance of zad_II_1). What I do wrong? This is code:</p> <pre><code>public class zad_II_1 { abstract class Pacjent{ String imie; Pacjent(String imie){ this.imie=imie; } abstract String nazwiskoo(); abstract String PodajChorobe(); abstract String PodajLek(); String nazwisko(){ return imie; } String choroba(){ return PodajChorobe(); } String leczenie(){ return PodajLek(); } } class ChoryNaGlowe extends Pacjent{ ChoryNaGlowe(String imie){ super(imie);} String nazwiskoo(){ return imie; } String PodajChorobe(){return "glowa";} String PodajLek(){return "aspiryna";} } class ChoryNaNoge extends Pacjent{ ChoryNaNoge(String imie){ super(imie);} String nazwiskoo(){ return imie; } String PodajChorobe(){return "noga";} String PodajLek(){return "gips";} } class ChoryNaDyspepsje extends Pacjent{ ChoryNaDyspepsje(String imie){ super(imie);} String nazwiskoo(){ return imie; } String PodajChorobe(){return "dyspepsja";} String PodajLek(){return "wegiel";} } public static void main(String[] args) { Pacjent[] pacjenci = { new ChoryNaGlowe("Janek"), new ChoryNaNoge("Edzio"), new ChoryNaDyspepsje("Marian") }; for (Pacjent p : pacjenci) { System.out.println("Pacjent: " + p.nazwisko() + '\n' + "Chory na: " + p.choroba() + '\n' + "Zastosowano: " + p.leczenie() +"\n\n" ); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload