NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package clientlight;

/**
*
* @author mfayyaz.bese17seecs
*/

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;


@SuppressWarnings("unused")

interface IShapeInterface{

public void draw(String graphicType,
int x, int y,
int width, int height,
String color, boolean fill);
}

class Rectangle implements IShapeInterface{

public void draw(String graphicType,
int x, int y,
int width, int height,
String color, boolean fill){
System.out.println("Shape: " +graphicType+"X: "+x+"Y: "+y+"Width: "+width+"Height: "
+height+"Color: "+color+ "Fill: "+fill);
}

}
class Triangle implements IShapeInterface{

public void draw(String graphicType,
int x, int y,
int width, int height,
String color, boolean fill){
System.out.println("Shape: " +graphicType+"X: "+x+"Y: "+y+"Width: "+width+"Height: "
+height+"Color: "+color+ "Fill: "+fill);
}

}
class Square implements IShapeInterface{

public void draw(String graphicType,
int x, int y,
int width, int height,
String color, boolean fill){
System.out.println("Shape: " +graphicType+"X: "+x+"Y: "+y+"Width: "+width+"Height: "
+height+"Color: "+color+ "Fill: "+fill);
}

}
class Circle implements IShapeInterface{

public void draw(String graphicType,
int x, int y,
int width, int height,
String color, boolean fill){
System.out.println("Shape: " +graphicType+"X: "+x+"Y: "+y+"Width: "+width+"Height: "
+height+"Color: "+color+ "Fill: "+fill);
}

}
class Oval implements IShapeInterface{

public void draw(String graphicType,
int x, int y,
int width, int height,
String color, boolean fill){
System.out.println("Shape: " +graphicType+"X: "+x+"Y: "+y+"Width: "+width+"Height: "
+height+"Color: "+color+ "Fill: "+fill);
}

}
class Parallelogram implements IShapeInterface{

public void draw(String graphicType,
int x, int y,
int width, int height,
String color, boolean fill){
System.out.println("Shape: " +graphicType+"X: "+x+"Y: "+y+"Width: "+width+"Height: "
+height+"Color: "+color+ "Fill: "+fill);
}

}
class Hexagon implements IShapeInterface{

public void draw(String graphicType,
int x, int y,
int width, int height,
String color, boolean fill){
System.out.println("Shape: " +graphicType+"X: "+x+"Y: "+y+"Width: "+width+"Height: "
+height+"Color: "+color+ "Fill: "+fill);
}

}
class Sphere implements IShapeInterface{

public void draw(String graphicType,
int x, int y,
int width, int height,
String color, boolean fill){
System.out.println("Shape: " +graphicType+"X: "+x+"Y: "+y+"Width: "+width+"Height: "
+height+"Color: "+color+ "Fill: "+fill);
}

}
class ShapeFactory{
public static HashMap <String, IShapeInterface> hmap = new HashMap<String,IShapeInterface>();
public static IShapeInterface getShape(String type){
IShapeInterface s = null;
if (hmap.get(type) != null){
s = hmap.get(type);
}
else{
switch(type){
case "rc":
s= new Rectangle();

break;
case "tr":
s= new Triangle();
break;
case "sq":
s= new Square();
break;
case "ci":
s= new Circle();
break;
case "ov":
s= new Oval();
break;
case "pa":
s= new Parallelogram();
break;
case "he":
s= new Hexagon();
break;
case "sp":
s= new Sphere();
break;

}
hmap.put(type, s);

}
return hmap.get(type);
}
}
public class ClientLight {


private static final int WIDTH = 1800, HEIGHT = 1600;

//rc=rectangle, tr=triangle, sq=square, ci=circle, ov=oval, pa=parallelogram, he=hexagon, sp=sphere
private static final String shapes[] = { "rc", "tr", "sq", "ci", "ov", "pa", "he", "sp"};

String colors[] = { "red", "green", "blue", "darkGray" };
private static final boolean fill[] = { true, false };


public ClientLight() {
ShapeFactory sobj;
int i;
for(i = 0; i < 100; ++i) {
sobj = new ShapeFactory();
IShapeInterface iobj = sobj.getShape(getRandomShape());
iobj.draw(" ",getRandomX(),getRandomY(),getRandomWidth(),getRandomHeight(),getRandomColor(),getRandomFill());
System.out.println("Hashmap size: " + ShapeFactory.hmap.size());
}
}

private String getRandomShape() {return shapes[(int) (Math.random() * shapes.length)];}
private int getRandomX() {return (int) (Math.random() * WIDTH*0.9);}
private int getRandomY() {return (int) (Math.random() * HEIGHT*0.8);}
private int getRandomWidth(){return (int) (Math.random() * (WIDTH / 7));}
private int getRandomHeight() {return (int) (Math.random() * (HEIGHT / 7));}
private String getRandomColor() {return colors[(int) (Math.random() * colors.length)];}
private boolean getRandomFill() {return fill[(int) (Math.random() * fill.length)];}

public static void main(String[] args) {
ClientLight client = new ClientLight();

}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.