gb-java-devel/jc4-04.tex

73 lines
1.5 KiB
TeX
Raw Normal View History

2022-10-18 23:35:47 +03:00
% enum Color{
% RED("#FF0000"), BLUE("#0000FF"), GREEN("#00FF00");
% private String code;
% Color(String code){
% this.code = code;
% }
% public String getCode(){ return code;}
% }
%public class Main{
% public static void main(String[] args) {
% System.out.println(Color.RED.getCode());
% System.out.println(Color.GREEN.getCode());
% }
%}
% package ru.gb.jcore;
% public class Orange {
% public void squeezeJuice(){
% System.out.println("Squeeze juice ...");
% }
% class Juice{
% public void flow(){
% System.out.println("Juice dripped ...");
% }
% }
% }
% package ru.gb.jcore;
% public class Main {
% public static void main(String[] args) {
% Orange orange = new Orange();
% Orange.Juice juice = orange.new Juice();
% orange.squeezeJuice();
% juice.flow();
% }
% }
%///////////////////////////////
% public class Orange {
% private Juice juice;
% public Orange(){
% this.juice = new Juice();
% }
% public void squeezeJuice(){
% System.out.println("Squeeze juice ...");
% juice.flow();
% }
% private class Juice{
% public void flow(){
% System.out.println("Juice dripped ...");
% }
% }
% }
% public class Main {
% public static void main(String[] args) {
% Orange orange = new Orange();
% orange.squeezeJuice();
% }
% }