Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package A14;
- public class BigAndSmall extends Dekorierer {
- BigAndSmall(ChConv c){
- super (c);
- }
- @Override
- char fetch() {
- char c = ch.fetch();
- if(c>='A'&&c<='Z')return (char)(c+'a'-'A');
- else if(c>='a'&&c<='z')return (char) (c+'A'-'a');
- else return c;
- }
- }
- package A14;
- abstract class ChConv {
- abstract char fetch();
- }
- package A14;
- public class ConstString extends ChConv{
- String text = "keep cool";
- int x = 0;
- char fetch(){
- if(x<text.length()){
- return text.charAt(x++);
- }
- return ' ';
- }
- }
- package A14;
- abstract class Dekorierer extends ChConv{
- ChConv ch;
- Dekorierer(ChConv c){
- ch = c;
- }
- }
- package A14;
- public class MainA14 {
- public static void main(String args[]){
- ChConv c = new BigAndSmall(new ParaString("Hallo"));
- for(int i = 0; i<15; i++)System.out.println(c.fetch());
- }
- }
- package A14;
- public class ParaString extends ChConv {
- ParaString(String s){
- text = s;
- }
- String text;
- int x = 0;
- char fetch(){
- if(x<text.length()){
- return text.charAt(x++);
- }
- return ' ';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement