Little ginger's java

java

Validate palindrome string

Validate palindrome string. Write a program to verify whether a string is a palindrome string: whether to read it from the front and read it from the back are the same. For example, mom and dad are palindromes. The program receives the string input by the user, determines whether it is a palindrome string, and then outputs the judgment result. Ignore case, spaces, and punctuation when validating palindrome strings. The example output is shown in Figure 1 and Figure 2.

package work1;
import javax.swing.JOptionPane;

public class huiwen {
    public static void main(String[] args) {
        String str = JOptionPane.showInputDialog("Please enter a string:");
        if(ishuiwen(str))
        {
            JOptionPane.showMessageDialog(null,str+"It's palindrome");
        }
        else
            JOptionPane.showMessageDialog(null,str+"Not palindromes");
    }
    public static boolean ishuiwen(String s) {
        int i = 0, j = s.length() - 1;
        s = s.toLowerCase();
        while(i < j) {
            if (!Character.isLetterOrDigit(s.charAt(i))) {
                i++;
                continue;
            }
            if (!Character.isLetterOrDigit(s.charAt(j))) {
                j--;
                continue;
            }
            if (s.charAt(j) != s.charAt(i)) {
                return false;
            }
            i++;
            j--;
        }
        return true;
    }

}

tic-tac-toe

Write a program to realize a simple Sanzi game. In Sanzi, the two sides play chess in turn in 33 chessboards. One side is represented by and the other side is represented by O. If a party's three pieces occupy the same row, column or diagonal, the party wins. If the chessboard is full of pieces, but no one wins, there will be a draw. In the program, one side is the user, and the user inputs the position of each chess game on the interface; The position of the other side playing chess is generated randomly and automatically. The example output is shown in the figure.

package work1;
import javax.swing.JOptionPane;
public class sanziqi {
    public static void main(String[] args) {
        char []s=new char[9];
        for(int i=0;i<9;i++) {
            s[i]=(char)(i+49);
        }
        int i=0;
        while(i++<5) {
            String str=
                    JOptionPane.showInputDialog("------------------\n"
                            +"|  "+s[0]+"  |  "+s[1]+"  |  "+s[2]+"  |\n"
                            +"|  "+s[3]+"  |  "+s[4]+"  |  "+s[5]+"  |\n"
                            +"|  "+s[6]+"  |  "+s[7]+"  |  "+s[8]+"  |\n"
                            +"------------------\n"
                            + "Please enter the location:");
            while(str.length()==0||(str.charAt(0)-49)<0||(str.charAt(0)-49)>8) {
                str=
                        JOptionPane.showInputDialog("------------------\n"
                                +"|  "+s[0]+"  |  "+s[1]+"  |  "+s[2]+"  |\n"
                                +"|  "+s[3]+"  |  "+s[4]+"  |  "+s[5]+"  |\n"
                                +"|  "+s[6]+"  |  "+s[7]+"  |  "+s[8]+"  |\n"
                                +"------------------\n"
                                + "Input error, please re-enter:");
            }
            char index=str.charAt(0);
            while(s[index-49]=='*'||s[index-49]=='o') {
                str=
                        JOptionPane.showInputDialog("------------------\n"
                                +"|  "+s[0]+"  |  "+s[1]+"  |  "+s[2]+"  |\n"
                                +"|  "+s[3]+"  |  "+s[4]+"  |  "+s[5]+"  |\n"
                                +"|  "+s[6]+"  |  "+s[7]+"  |  "+s[8]+"  |\n"
                                +"------------------\n"
                                + "This location is occupied, please re-enter:");
                index=str.charAt(0);
                while(str.length()==0||(str.charAt(0)-49)<0||(str.charAt(0)-49)>8) {
                    str=
                            JOptionPane.showInputDialog("------------------\n"
                                    +"|  "+s[0]+"  |  "+s[1]+"  |  "+s[2]+"  |\n"
                                    +"|  "+s[3]+"  |  "+s[4]+"  |  "+s[5]+"  |\n"
                                    +"|  "+s[6]+"  |  "+s[7]+"  |  "+s[8]+"  |\n"
                                    +"------------------\n"
                                    + "Input error, please re-enter:");
                }
            }
            s[index-49]='*';
            if((s[0]=='*'&&s[3]=='*'&&s[6]=='*')||
                    (s[1]=='*'&&s[4]=='*'&&s[7]=='*')||
                    (s[2]=='*'&&s[5]=='*'&&s[8]=='*')||
                    (s[0]=='*'&&s[1]=='*'&&s[2]=='*')||
                    (s[3]=='*'&&s[4]=='*'&&s[5]=='*')||
                    (s[6]=='*'&&s[7]=='*'&&s[8]=='*')||
                    (s[0]=='*'&&s[4]=='*'&&s[8]=='*')||
                    (s[2]=='*'&&s[4]=='*'&&s[6]=='*')) {
                JOptionPane.showMessageDialog(null, "------------------\n"
                        +"|  "+s[0]+"  |  "+s[1]+"  |  "+s[2]+"  |\n"
                        +"|  "+s[3]+"  |  "+s[4]+"  |  "+s[5]+"  |\n"
                        +"|  "+s[6]+"  |  "+s[7]+"  |  "+s[8]+"  |\n"
                        +"------------------\n"
                        + "Congratulations on winning"
                );
                break;
            }
            int b=(int)(Math.random()*9);
            while(s[b]=='*'||s[b]=='o')
            {
                b=(int)(Math.random()*9);
            }
            s[b]='o';
            if((s[0]=='o'&&s[3]=='o'&&s[6]=='o')||
                    (s[1]=='o'&&s[4]=='o'&&s[7]=='o')||
                    (s[2]=='o'&&s[5]=='o'&&s[8]=='o')||
                    (s[0]=='o'&&s[1]=='o'&&s[2]=='o')||
                    (s[3]=='o'&&s[4]=='o'&&s[5]=='o')||
                    (s[6]=='o'&&s[7]=='o'&&s[8]=='o')||
                    (s[0]=='o'&&s[4]=='o'&&s[8]=='o')||
                    (s[2]=='o'&&s[4]=='o'&&s[6]=='o')) {
                JOptionPane.showMessageDialog(null, "------------------\n"
                        +"|  "+s[0]+"  |  "+s[1]+"  |  "+s[2]+"  |\n"
                        +"|  "+s[3]+"  |  "+s[4]+"  |  "+s[5]+"  |\n"
                        +"|  "+s[6]+"  |  "+s[7]+"  |  "+s[8]+"  |\n"
                        +"------------------\n"
                        + "failed"
                );
                break;
            }

        }
        if(i==6) {
            JOptionPane.showMessageDialog(null, "------------------\n"
                    +"|  "+s[0]+"  |  "+s[1]+"  |  "+s[2]+"  |\n"
                    +"|  "+s[3]+"  |  "+s[4]+"  |  "+s[5]+"  |\n"
                    +"|  "+s[6]+"  |  "+s[7]+"  |  "+s[8]+"  |\n"
                    +"------------------\n"
                    + "it ends in a draw"
            );
        }
    }
}

Plural class

Write a complex class, which can carry out complex addition and subtraction. Write a class (application) containing the main method to test the complex class. The complex number class is required to include at least one construction method without parameters and one construction method with parameters; The data member includes the real part and imaginary part of the complex number, which is of double type; It includes two methods to realize the addition and subtraction of complex numbers respectively. The example output is shown in the figure.

package work2;
import javax.swing.JOptionPane;
public class fushu {
    private double x;
    private double y;
    public fushu(){}
    public fushu(double a,double b)
    {
        x=a;
        y=b;
    }
    public fushu add(fushu k)
    {
        this.x=x+k.x;
        this.y=y+k.y;
        return this;
    }
    public fushu sub(fushu k)
    {
        this.x=x-k.x;
        this.y=y-k.y;
        return this;
    }
    public static void main(String[] args)
    {
        fushu n=new fushu(5.60,7.40);
        fushu m=new fushu(1.20,3.40);
        fushu o=new fushu(5.60,7.40);
        fushu p=new fushu(1.20,3.40);
        fushu l=new fushu(5.60,7.40);
        fushu u=new fushu(1.20,3.40);
        l.add(u);
        o.sub(p);
        JOptionPane.showMessageDialog(null,"n="+n.x+"i+"+n.y+"\n"
                +"m="+m.x+"i+"+m.y+"\n"
                +"n+m="+l.x+"i+"+l.y+"\n"
                +"n-m="+String.format("%.1f", o.x)+"i+"+o.y+"\n");
    }
}

Book borrowing

Write three categories, books, students and tests, which can deal with simple book borrowing, including borrowing and returning books. The data members of books include book title, book number and students who borrow books; Methods include borrowing books, returning books and displaying book information. Data members of student class include name, student number and books borrowed; Methods include displaying student information and so on. Test class is an application program in which book class and student class objects are created to complete the borrowing and return of books. (file version, the difference lies in the store function)

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;

public class library {
    private String name;
    private String number;
    private String student;
    private int k;//Lending or not
    public library(String name,String number)
    {
        this.name=name;
        this.number=number;
        this.k=0;//Not lent
    }
    public void lend(String student)
    {
        this.student=student;
        this.k=1;
    }
    public void re()
    {
        k=0;
    }
    public String getName() {
        return name;
    }
    public void store()
    {
        try
        {
            //The PrintWriter class can write various types of data in text format
            PrintWriter out=new PrintWriter(new FileWriter("output.txt",true));//true means append, otherwise the previous content will be overwritten each time
            //Display each time with properties
            Properties res=new Properties();
            res.store(out,"Book Information");

            out.println("title:"+name);
            out.println("Book No.:"+number);
            out.print("Borrowing:");
            if(k==0)
                out.println("Not lent");
            else
            {
                out.println("Lent");
                out.println("Borrowing students:"+student);
            }
            out.println();
            out.close();
        }
        catch(IOException exception)
        {
            exception.printStackTrace();
        }
    }

    public void display()
    {
        System.out.println("Book information");
        System.out.print("title:"+name+"\n Book No.:"+number+"\n Borrowing:");
        if(k==0)
            System.out.println("Not lent");
        else
            System.out.println("Lent\n"+"Borrowing students:"+student);
        store();
    }
}

public class STU {
    private String name1;
    private String number1;
    private String bookname[];
    private int count;//Number of books borrowed

    public STU(String s,String n)
    {
        name1=s;
        number1=n;
        count=0;
        bookname=new String [10];
    }

    public void borrrow(String bookname)
    {
        this.bookname[count]=bookname;
        number1+=1;
    }

    //Return the book
    public void Return(String b)
    {
        for(int i=0;i<count;i++)
        {
            if(bookname[i]==b)
            {
                for(int j=i;j<count;j++)
                {
                    bookname[j]=bookname[j+1];
                }
            }
        }
        count-=1;
    }

    public void display()
    {
        System.out.println("Student information");
        System.out.print("Student Name:"+name1+"\n Student number:"+number1+"\n");

        if(count!=0)
        {
            System.out.print("Borrow books:");
            for(int i=0;i<count;i++)
                System.out.print("<"+bookname[i]+">");
            System.out.print("\n");
        }
    }
}
package work2;
import javax.swing.JOptionPane;

public class test {
    public static void main(String[] args) {
        String name= JOptionPane.showInputDialog("Please enter student name:");
        String number=JOptionPane.showInputDialog("Please enter student number:");

        STU s=new STU(name,number);
        library[] b=new library[3];

        b[0]=new library("Snow White","001");
        b[1]=new library("Journey to the West","002");
        b[2]=new library("The Dream of Red Mansion","003");

        //Borrow books
        b[0].lend(name);
        b[1].lend(name);
        b[2].lend(name);
        s.borrrow(b[0].getName());
        s.borrrow(b[1].getName());
        s.borrrow(b[2].getName());

        //display
        s.display();
        System.out.print("\n");
        for(library book:b)
        {
            book.display();
            System.out.print("\n");
        }

        //Return the book
        b[0].re();
        b[1].re();
        s.Return(b[0].getName());
        s.Return(b[1].getName());

        //display
        s.display();
        System.out.print("\n");
        for(library book:b)
        {
            book.display();
            System.out.print("\n");
        }
    }
}

Employee class hierarchy

Create four classes: Employee class, SalariedEmplyee class, HourlyEmployee class and CommissionEmployee class. The Employee class is the parent of the other three classes. The Employee class contains name and ID number. In addition, SalariedEmployee class should also include monthly salary; HourlyEmployee class should also include hourly wages and working hours; CommissionEmployee should also include the percentage of commission and total sales. Each class should have appropriate construction methods, data member settings and reading methods. Write an application, create the objects of these classes, and output the information related to the objects. Note that subclasses sometimes need to call the construction method and overridden method of the parent class. The member variable is defined as private, and some methods are overloaded.

package work3;

import javax.swing.*;

public class CommissionEmployee extends Employee{
    private double commission;
    private double sales;

    CommissionEmployee() {
    }

    //heavy load
    CommissionEmployee(String a,String b,double c,double d){
        this.setName(a);
        this.setId(b);
        commission=c;
        sales=d;
    }

    public double getCommission() {
        return commission;
    }

    public void setCommission(double commission) {
        this.commission = commission;
    }

    public double getSales() {
        return sales;
    }

    public void setSales(double sales) {
        this.sales = sales;
    }

    //cover
    public void show(){
        JOptionPane.showMessageDialog(null,"name="+this.getName()+"\ncardId="+this.getId()+"\ncommission="+commission+"\nsales="+sales,"CommissionEmployee",JOptionPane.INFORMATION_MESSAGE);
    }
}

package work3;
import javax.swing.*;

public class Employee {
    private String name;
    private String cardid;
    public Employee() { }

    public String getName() {
        return name;
    }

    public void setName(String name) { this.name = name; }

    public String getId() {
        return cardid;
    }

    public void setId(String id) {
        this.cardid = id;
    }

    public void show(){
        JOptionPane.showMessageDialog(null,"name="+name+"\ncardId="+cardid,"Employee",JOptionPane.INFORMATION_MESSAGE);
    }
}

package work3;

import javax.swing.*;

public class HourlyEmployee extends Employee{
    private double money_hour;
    private double hour;

    HourlyEmployee() {
    }

    public double getMoney_hour() {
        return money_hour;
    }

    public void setMoney_hour(double hour_rate) {
        this.money_hour = hour_rate;
    }

    public double gethour() {
        return hour;
    }

    public void sethour(double work_hour) {
        this.hour = hour;
    }

    public void show(){
        JOptionPane.showMessageDialog(null,"name="+this.getName()+"\ncardId="+this.getId()+"\nhour_rate="+money_hour+"\nwork_hour="+hour,"HourlyEmployee",JOptionPane.INFORMATION_MESSAGE);
    }
}

package work3;

import javax.swing.*;

public class SalariedEmplyee extends Employee {
    private double salary;

    SalariedEmplyee() {
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public void show(){
        JOptionPane.showMessageDialog(null,"name="+this.getName()+"\nCardId="+this.getId()+"\nsalary="+salary,"SalariedEmplyee",JOptionPane.INFORMATION_MESSAGE);
    }
}

package work3;

public class test {
    public static void main(String[] args) {

        Employee a = new Employee();
        a.setId("6666666");
        a.setName("JIANGJIANG");
        a.show();


        SalariedEmplyee b = new SalariedEmplyee();
        b.setId("333333");
        b.setSalary(888);
        b.setName("tiantian");
        b.show();

        HourlyEmployee c = new HourlyEmployee();
        c.setId("444444");
        c.setMoney_hour(555);
        c.setName("jiangjiang");
        c.sethour(12);
        c.show();

        CommissionEmployee d = new CommissionEmployee();
        d.setCommission(333);
        d.setId("jianglai");
        d.setSales(999);
        d.setName("jiangjiang");
        d.show();
    }
}

Display function image

Displays the function image. Write a program and draw the image of function f(x)=x*x. The output example is shown in the figure below.

package work4;
import java.awt.EventQueue;
import javax.swing.JFrame;
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class DisplayFunction {

    public  static void main(String[] args) {
        EventQueue.invokeLater(() ->
        {
            DrawFrame frame = new DrawFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
        });

    }
}

class DrawFrame extends JFrame
{
    public DrawFrame()
    {
        setSize(600, 400);
        setTitle("Display function image");//Title Block text
        setLocation(500, 500);//Set form position
        add(new DrawComponent());
        pack();
    }
}
class DrawComponent extends JComponent
{
    private static final int DEFAULT_WIDTH = 400;
    private static final int DEFAULT_HEIGHT = 400;

    public void paintComponent(Graphics g)
    {

        Graphics2D g2 = (Graphics2D) g;
        double xCenter = DEFAULT_WIDTH / 2.0;//Center point x
        double yCenter = DEFAULT_HEIGHT / 2.0;//Center point y
        Line2D linex = new Line2D.Double(xCenter - 150, yCenter, xCenter + 150, yCenter);
        Line2D liney = new Line2D.Double(xCenter, yCenter - 150, xCenter, yCenter + 150);
        Line2D line1 = new Line2D.Double(xCenter + 150, yCenter, xCenter + 140, yCenter - 10);
        Line2D line2 = new Line2D.Double(xCenter + 150, yCenter, xCenter + 140, yCenter + 10);
        Line2D line3 = new Line2D.Double(xCenter, yCenter - 150, xCenter + 10, yCenter - 140);
        Line2D line4 = new Line2D.Double(xCenter, yCenter - 150, xCenter - 10, yCenter - 140);
        g2.draw(linex);
        g2.draw(liney);
        g2.draw(line1);
        g2.draw(line2);
        g2.draw(line3);
        g2.draw(line4);
        int[] arrayy = new int[200];
        int[] arrayx = new int[200];
        arrayx[0] = -100;
        for (int i = 0; i < 199; i++) {
            arrayx[i + 1] = arrayx[0] + i;
        }
        for (int i = 0; i < 200; i++) {
            arrayy[i] = -Function(arrayx[i]) /10;
        }

        for (int i = 0; i < 200; i++) {
            arrayx[i] = arrayx[i]+(int)xCenter;
            arrayy[i] = arrayy[i]+(int)yCenter;

        }
        g2.drawPolyline(arrayx, arrayy, 200);

    }
    public static int Function(int x)
    {
        return x * x;
    }
    public Dimension getPreferredSize()
    {
        return new Dimension(400,400);
    }
}


Display clock

Displays the clock. Write a program to display a clock. The sample output is shown in the following figure.

package work4;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.JLabel;


import javax.swing.JFrame;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class DisplayClock extends JFrame {
    MyPanel clockPanel;
    Ellipse2D.Double e;
    int x;
    int y;
    Line2D.Double hourLine;
    int hourLinex;
    int hourLiney;
    Line2D.Double minLine;
    int minLinex;
    int minLiney;
    Line2D.Double secondLine;
    int secondLinex;
    int secondLiney;
    GregorianCalendar calendar;
    int hour;
    int minute;
    int second;
    public static final int X = 125;
    public static final int Y = 125;
    public static final int RADIAN = 100;

    JLabel label1 = new JLabel("Hour" + hour + "Minute" + minute + "second" + second);

    public DisplayClock() {
        setBounds(400,200,300,400);
        clockPanel = new MyPanel();
        label1.setBounds(50, 235, 200, 30);
        label1.setForeground(Color.red);
        add(label1);
        add(clockPanel);
        Timer t = new Timer();
        Task task = new Task();
        t.schedule(task, 0, 1000);
    }

    public static void main(String[] args) {
        DisplayClock t = new DisplayClock();
        t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        t.setSize(300, 300);
        t.setVisible(true);

    }
    class MyPanel extends JPanel
    {
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) g;
            int i = 0;
            for(i = 0; i < 60; i ++)
            {
                int zx1 = (int) (X + 100  * Math.sin(i * (Math.PI / 30) ));
                int zy1 = (int) (Y + 100  * Math.cos(i * (Math.PI / 30) ));
                int h;
                if( i % 5 == 0)
                    h = 90;
                else
                    h = 95;
                int zx2 = (int) (X + h  * Math.sin(i * (Math.PI / 30) ));
                int zy2 = (int) (Y + h  * Math.cos(i * (Math.PI / 30) ));
                g2.setColor(Color.red);
                g2.drawLine(zx1, zy1, zx2, zy2);
            }
            g2.setColor(Color.black);
            g2.drawString("12", 120, 22);
            g2.drawString("6", 122, 238);
            g2.drawString("9", 15, 130);
            g2.drawString("3", 228, 130);
            g2.drawOval(25, 25, 200, 200);
            g2.setColor(Color.green);
            g2.drawLine(X, Y, hourLinex, hourLiney);
            g2.setColor(Color.blue);
            g2.drawLine(X, Y, minLinex, minLiney);
            g2.setColor(Color.red);
            g2.drawLine(X, Y, secondLinex, secondLiney);
        }
    }

    class Task extends TimerTask {
        public void run() {
            calendar = new GregorianCalendar();
            hour = calendar.get(Calendar.HOUR);
            minute = calendar.get(Calendar.MINUTE);
            second = calendar.get(Calendar.SECOND);

            hourLinex = (int) (X + 60 * Math.sin(hour * (Math.PI / 6)));
            hourLiney = (int) (Y - 60 * Math.cos(hour * (Math.PI / 6)));

            minLinex = (int) (X + 75  * Math.sin(minute * (Math.PI / 30)));
            minLiney = (int) (Y - 75  * Math.cos(minute * (Math.PI / 30)));

            secondLinex = (int) (X + 85  * Math.sin(second * (Math.PI / 30)) );
            secondLiney = (int) (Y - 85  * Math.cos(second * (Math.PI / 30)) );

            label1.setText("Hour:" + hour + "  " + "Minute:"+ minute + "  " + "second:" + second);
            repaint();
        }
    }
}

Draw random image

Define four classes, MyShape, MyLine, MyRectangle and MyOval, where MyShape is the parent of the other three classes. MyShape is an abstract class, including four coordinates of graphic position; A parameterless construction method, set all coordinates to 0; A constructor with parameters that sets all coordinates to corresponding values; Setting and reading method of each coordinate; abstract void draw(Graphics g) method. MyLine class is responsible for drawing straight lines and implementing the draw method of the parent class; MyRectangle is responsible for drawing rectangles and implementing the draw method of the parent class; MyOval is responsible for drawing ellipses and implementing the draw method of the parent class. Write an application, use the class defined above, randomly select the position and shape, and draw 20 graphics. The sample output is shown below

package work4;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.JLabel;


import javax.swing.JFrame;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class DisplayClock extends JFrame {
    MyPanel clockPanel;
    Ellipse2D.Double e;
    int x;
    int y;
    Line2D.Double hourLine;
    int hourLinex;
    int hourLiney;
    Line2D.Double minLine;
    int minLinex;
    int minLiney;
    Line2D.Double secondLine;
    int secondLinex;
    int secondLiney;
    GregorianCalendar calendar;
    int hour;
    int minute;
    int second;
    public static final int X = 125;
    public static final int Y = 125;
    public static final int RADIAN = 100;

    JLabel label1 = new JLabel("Hour" + hour + "Minute" + minute + "second" + second);

    public DisplayClock() {
        setBounds(400,200,300,400);
        clockPanel = new MyPanel();
        label1.setBounds(50, 235, 200, 30);
        label1.setForeground(Color.red);
        add(label1);
        add(clockPanel);
        Timer t = new Timer();
        Task task = new Task();
        t.schedule(task, 0, 1000);
    }

    public static void main(String[] args) {
        DisplayClock t = new DisplayClock();
        t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        t.setSize(300, 300);
        t.setVisible(true);

    }
    class MyPanel extends JPanel
    {
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) g;
            int i = 0;
            for(i = 0; i < 60; i ++)
            {
                int zx1 = (int) (X + 100  * Math.sin(i * (Math.PI / 30) ));
                int zy1 = (int) (Y + 100  * Math.cos(i * (Math.PI / 30) ));
                int h;
                if( i % 5 == 0)
                    h = 90;
                else
                    h = 95;
                int zx2 = (int) (X + h  * Math.sin(i * (Math.PI / 30) ));
                int zy2 = (int) (Y + h  * Math.cos(i * (Math.PI / 30) ));
                g2.setColor(Color.red);
                g2.drawLine(zx1, zy1, zx2, zy2);
            }
            g2.setColor(Color.black);
            g2.drawString("12", 120, 22);
            g2.drawString("6", 122, 238);
            g2.drawString("9", 15, 130);
            g2.drawString("3", 228, 130);
            g2.drawOval(25, 25, 200, 200);
            g2.setColor(Color.green);
            g2.drawLine(X, Y, hourLinex, hourLiney);
            g2.setColor(Color.blue);
            g2.drawLine(X, Y, minLinex, minLiney);
            g2.setColor(Color.red);
            g2.drawLine(X, Y, secondLinex, secondLiney);
        }
    }

    class Task extends TimerTask {
        public void run() {
            calendar = new GregorianCalendar();
            hour = calendar.get(Calendar.HOUR);
            minute = calendar.get(Calendar.MINUTE);
            second = calendar.get(Calendar.SECOND);

            hourLinex = (int) (X + 60 * Math.sin(hour * (Math.PI / 6)));
            hourLiney = (int) (Y - 60 * Math.cos(hour * (Math.PI / 6)));

            minLinex = (int) (X + 75  * Math.sin(minute * (Math.PI / 30)));
            minLiney = (int) (Y - 75  * Math.cos(minute * (Math.PI / 30)));

            secondLinex = (int) (X + 85  * Math.sin(second * (Math.PI / 30)) );
            secondLiney = (int) (Y - 85  * Math.cos(second * (Math.PI / 30)) );

            label1.setText("Hour:" + hour + "  " + "Minute:"+ minute + "  " + "second:" + second);
            repaint();
        }
    }
}

Show expression

Write a program to display different expressions. At least 4 buttons are included on the window to control the display of different expressions and exit the program respectively. The sample output is shown in the following figure.

package work5;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DisplayEmoji extends JFrame {
    JPanel frame;
    JButton cry;
    JButton smile;
    JButton angry;
    JButton exit;
    JLabel label;
    ImageIcon icon1 = new ImageIcon("src\\work5\\cry.jpg");
    ImageIcon icon2 = new ImageIcon("src\\work5\\smile.jpg");
    ImageIcon icon3 = new ImageIcon("src\\work5\\angry.jpg");
}
 class Test_Frame extends DisplayEmoji{
    public Test_Frame() {//Constructor to build the display interface
        frame = new JPanel();//Create panel components
        getContentPane().add(frame,BorderLayout.CENTER);
        //Get the default content panel first, and then in the borderlayout. Of the default content panel Add frame panel at center position
        frame.setLayout(null);//No default typesetting
        frame.setBounds(200,200,400,300);//Panel size location
        this.setBounds(400,100,480,380);//Set the position and size of the form. this can be omitted
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //The program executes when the user clicks close
        setTitle("Show expression");//Set form title
        setVisible(true);//Set form visibility
        //Set text picture label
        label = new JLabel();
        frame.add(label);
        label.setBounds(90,30,300,200);
        label.setText("Please click the button");
        label.setFont(new Font(null, Font.PLAIN, 35));
        //Set tear button
        cry = new JButton("shed tears");
        frame.add(cry);
        cry.setBounds(150,250,60,30);
        cry.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                label.setIcon(icon1);
            }
        });
        //Set smile button
        smile = new JButton("smile");
        frame.add(smile);
        smile.setBounds(50,250,60,30);
        smile.addActionListener(new ActionListener() {//action
            public void actionPerformed(ActionEvent e) {
                label.setIcon(icon2);
            }
        });

        //Set angry button
        angry = new JButton("get angry");
        frame.add(angry);
        angry.setBounds(250, 250, 60, 30);
        angry.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                label.setIcon(icon3);
            }
        });
        //sign out
        exit = new JButton("sign out");
        frame.add(exit);
        exit.setBounds(350, 250, 60, 30);
        exit.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                System.exit(0);
            }
        });

    }

    public static void main(String[] args) {
        Test_Frame test4_1 = new Test_Frame();
    }
}

Guessing program

Write a guessing program, which randomly selects an integer for users to guess in the range of 1 to 1000. If the number of guesses provided by the user interface is too large, the background will change to red. If the number of guesses provided by the user interface is too large, the background will change to red. After the user guesses correctly, the text box becomes non editable and prompts the user to guess correctly. A button is provided on the interface so that users can restart the game. The number of guesses of the user shall also be displayed on the interface. The sample output is shown in the following figure.

package work5;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class GuessNumber{

    public static void main(String[] args) {
        DrawFrame frame=new DrawFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}

class DrawFrame extends JFrame
{
    private static int count=0;//Guess times
    private int rightNumber;//Random numbers for guessing
    private JTextField text;//Number entered
    private JLabel tip;//Guess times prompt
    private JPanel panel;//Central input box part panel
    private JLabel result;//Guess result tips
    private JButton button1=new JButton("confirm");
    private JButton button2=new JButton("restart");
    private JButton button3=new JButton("sign out");

    public DrawFrame()
    {
        setSize(400,200);
        setTitle("Guess the number");
        rightNumber=(int)(Math.random()*100);

        //Add top times prompt
        tip=new JLabel("You already guessed"+count+"second",JLabel.LEFT);

        //Add central input box section
        panel = new JPanel();
        JLabel input=new JLabel("Enter the number of guesses");
        panel.add(input);
        text=new JTextField(20);
        panel.add(text);
        result=new JLabel();//Display guess results
        panel.add(result);

        //Add bottom button
        JPanel buttons= new JPanel();
        //The listener of the button has two classes, one class for the confirm button, and one class for the restart and exit
        ActionListener listener1=new ComfirmListener();
        button1.addActionListener(listener1);
        ActionListener listener2=new OtherListener();
        button2.addActionListener(listener2);
        button3.addActionListener(listener2);
        //Add button to panel
        buttons.add(button1);
        buttons.add(button2);
        buttons.add(button3);

        //Add each part to the frame and use the default BorderLayout layout
        add(tip,"North");
        add(panel,"Center");
        add(buttons,"South");
    }

    //Listener class for confirm button
    class ComfirmListener implements ActionListener
    {
        public void actionPerformed(ActionEvent event)
        {
            //Guess right
            if(Integer.parseInt(text.getText())==rightNumber)
            {
                //The setting text box is not editable
                text.setEditable(false);

                //Prompt guess times + 1
                tip.setText("You already guessed"+(++count)+"second");

                //Adjust the background color to the default background color
                Color defaultColor = getBackground();
                panel.setBackground(defaultColor);

                //Display guess results
                result.setText("You guessed right");
            }
            //less than
            else if(Integer.parseInt(text.getText())<rightNumber)
            {
                panel.setBackground(Color.blue);
                tip.setText("You already guessed"+(++count)+"second");
                result.setText("Guess too small");
            }
            else
            {
                panel.setBackground(Color.red);
                tip.setText("You already guessed"+(++count)+"second");
                result.setText("Guess too much");
            }
        }
    }

    //Listener for restart and exit buttons
    class OtherListener implements ActionListener
    {
        public void actionPerformed(ActionEvent event)
        {
            //restart
            if(event.getSource()==button2)
            {
                //Clear text box contents
                text.setText("");
                text.setEditable(true);

                //Reselect a number for guessing
                rightNumber=(int)(Math.random()*100);

                //Adjust the background color to the default background color
                Color defaultColor = getBackground();
                panel.setBackground(defaultColor);

                //Guess times set to 0
                count=0;
                tip.setText("You already guessed"+count+"second");

                //Clear the original guess
                result.setText("");
            }
            //Exit closes the window
            else
            {
                setVisible(false);
            }
        }
    }
}

producers and consumers

Write programs to achieve producer and consumer issues. Input: an indefinite length string array composed of English letters and numbers, such as {"abc", "23d", "1a"}. Every 100 milliseconds, the producer thread reads the data and puts it into the warehouse shared by the producer; The consumer takes out the string from the warehouse and inverts it, as shown in the above example {"cba", "d32", "a1"}; Output: inverted string.

package work6;

import java.util.concurrent.*;

public class PC {

    public static void main(String[] args) {
        BlockingQueue<String>q=new ArrayBlockingQueue<String>(1);
        String []s=new String[] {"abc1","c2","5h3","0u4","3rg5"};
        Thread P=new Thread(new Producer(q,s));
        Thread C=new Thread(new Consumer(q));
        P.start();
        C.start();
    }

}
//Producer process
class Producer implements Runnable
{
    private BlockingQueue<String>q=null;
    String []stringArray=new String[5];

    public Producer(BlockingQueue<String>q,String[]stringArray)
    {
        this.q=q;
        this.stringArray=stringArray;
    }

    public void run()
    {
        int i=0;
        while(true)
        {
            try
            {
                String s=new String(stringArray[i]);
                q.put(s);
                Thread.sleep(100);
            }
            catch(InterruptedException e)
            {
                e.printStackTrace();
            }
            i=(i+1)%5;
        }
    }
}
//Consumer process
class Consumer implements Runnable
{
    private BlockingQueue<String>q=null;

    public Consumer(BlockingQueue<String>q)
    {
        this.q=q;
    }

    public void run()
    {
        int i=0;
        while(i<100)
        {
            try
            {
                StringBuffer reverseS=new StringBuffer(q.take());
                reverseS.reverse();
                System.out.println(Thread.currentThread().getName()+":"+reverseS);
            }
            catch(InterruptedException e)
            {
                e.printStackTrace();
            }
            i++;
        }
    }
}

File processing

Write a program to count the number of characters and words in English text files. When the program runs, input the name of the file to be counted, and output the number of characters and words after the program processing.

package work6;


import javax.swing.*;
import java.io.*;

    public class EnglishCount {

        public static void main(String[] args) {
            String fileName=JOptionPane.showInputDialog("Please the name of a file");

            try
            {
                //Create file objects and read objects
                File in=new File(fileName);
                FileReader reader=new FileReader(in);

                //Read text file to character array letters
                char[] letters=new char[(int)in.length()];
                reader.read(letters);

                //Count the number of words
                String s=String.valueOf(letters);//char [] to String
                /*
                 * The meaning of the following functions:
                 * replaceAll(String regex, String replacement):Replace all regex matches with replacement
                 * trim():Remove a space at the beginning and end of String
                 * split():Splits the string according to the given regularity
                 */
                String[ ] words=s.replaceAll("[^a-zA-Z]+"," ").trim( ).split(" ");

                System.out.println("Number of characters:"+letters.length+"\n Number of words:"+words.length);
                reader.close();
            }
            catch(IOException exception)
            {
                exception.printStackTrace();
            }
        }
    }

Pinball program

The program can launch a pinball through a launch button. When the ball meets the boundary, it will bounce back automatically. After moving a fixed number of times, the ball will stop moving. It is required that each click on the launch button will launch a pinball. If it is clicked multiple times, multiple pinballs will move at the same time. The program can end the operation of the program through another end.

package work6;

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;

import javax.swing.*;


public class MoveBall extends JFrame
{
    //main program
    public static void main(String[] args){
        EventQueue.invokeLater(new Runnable()
        {
            public void run(){
                JFrame frame = new BounceFrame();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}
//Ball bounce
class BallRunable implements Runnable
{
    public BallRunable(Ball aBall,Component aComponent){
        ball = aBall;
        component = aComponent;
    }
    public void run(){
        try{
            for(int i=1;i<=STEPTS;i++)
            {
                ball.move(component.getBounds());
                component.repaint();
                Thread.sleep(DELAY);
            }
        }
        catch(InterruptedException e){
        }
    }
    private Ball ball;
    private Component component;
    public static final int STEPTS = 1000;
    public static final int DELAY = 5;
}
//Define form
class BounceFrame extends JFrame{
    public BounceFrame(){
        setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
        setTitle("MoveBall");

        comp = new BallComponent();
        add(comp,BorderLayout.CENTER);

        JPanel buttonPanel = new JPanel();
        addButton(buttonPanel,"start",new ActionListener()
        {
            public void actionPerformed(ActionEvent event)
            {
                addBall();
            }
        });
        addButton(buttonPanel,"end",new ActionListener()
        {
            public void actionPerformed(ActionEvent event)
            {
                System.exit(0);
            }
        });
        add(buttonPanel,BorderLayout.SOUTH);
    }
    public void addButton(Container c,String title,ActionListener listener)
    {
        JButton button = new JButton(title);
        c.add(button);
        button.addActionListener(listener);
    }
    public void addBall(){
        Ball b = new Ball();
        comp.add(b);
        Runnable r = new BallRunable(b,comp);
        Thread t = new Thread(r);
        t.start();
    }
    private BallComponent comp;
    public static final int DEFAULT_WIDTH = 450;
    public static final int DEFAULT_HEIGHT = 350;
    public static final int STEPS = 1000;
    public static final int DELAY = 3;
}
//Define ball
class Ball
{
    public void move(Rectangle2D bounds){
        x += dx;
        y += dy;
        if(x < bounds.getMinX()){
            x = bounds.getMinX();
            dx = -dx;
        }
        if(x + XSIZE >= bounds.getMaxX())
        {
            x = bounds.getMaxX() - XSIZE;
            dx = - dx;
        }
        if(y < bounds.getMinY())
        {
            y = bounds.getMinY();
            dy = - dy;
        }
        if(y + YSIZE >= bounds.getMaxY())
        {
            y = bounds.getMaxY() - YSIZE;
            dy = -dy;
        }
    }
    public void move(Component component, Object bounds) {
        // TODO Auto-generated method stub

    }
    public Ellipse2D getShape()
    {
        return new Ellipse2D.Double(x,y,XSIZE,YSIZE);
    }
    private static final int XSIZE = 15;
    private static final int YSIZE = 15;
    private double x = 0;
    private double y = 0;
    private double dx =1;
    private double dy = 1;
}
//Define the small ball display form
class BallComponent extends JPanel{
    public void add(Ball b)
    {
        balls.add(b);
    }
    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        for(Ball b : balls)
        {
            g2.fill(b.getShape());
        }
    }
    private ArrayList<Ball> balls = new ArrayList<Ball>();
}

Fan

Fan. Write a program to display 3 fans, and use the control button to start and stop the fan. You can start and stop three fans at the same time, or you can start and stop each fan separately. The output example is shown in the figure.

FanPanel: it realizes the drawing and rotation of the fan.

package test7;

import javax.swing.*;
import java.awt.*;

public class FanPanel extends JPanel{
	int angle1 = 10, angle2 = 100, angle3 = 190, angle4 = 280;
	int c;
	int x;
//	Override paint method
	public void paint(Graphics g) {
//		The paint method of the parent class must be called first
		super.paint(g);
		
		int x = 56;
		int y =55;
		int w = 170;
		int h = 170;
		g.drawArc(51, 50, 180, 180, 0, -360);
		g.drawLine(299, 0, 299, 260);
//		Draw sector
		g.setColor(Color.red);
//		g.fillArc(x, y, width, height, startAngle, arcAngle);
//		fillArc represents the filling diagram, startAngle represents the starting radian, and arcAngle represents the deflection angle
//		Each meaning can be understood by testing g.fillArc(0, 0, 100, 200, 0, 90)
		g.fillArc(x, y, w, h, angle1 + c, -30);
		g.fillArc(x, y, w, h, angle2 + c, -30);
		g.fillArc(x, y, w, h, angle3 + c, -30);
		g.fillArc(x, y, w, h, angle4 + c, -30);
		
		
	}
//   rotate
	public void Rotate(int num, int rev) {
		if(rev % 2 == 0) c += x;
		else c -= x;
		try  
        {  
            Thread.sleep(100/num);  
        }catch(Exception e)  
        {     
            e.printStackTrace();  
        }  
        repaint();  
	}
	
}

FanFrame: the layout of buttons and fans is realized, and the whole page is put up

package test7;

import javax.swing.*;
//import java.awt.*;
import java.awt.event.*;

public class FanFrame extends JFrame implements ActionListener,AdjustmentListener{
//	flag_n indicates whether the nth fan starts
	boolean flag_1 = false;
	boolean flag_2 = false;
	boolean flag_3 = false;
//	Change the direction of rotation
	int rev_1 = 0;
	int rev_2 = 0;
	int rev_3 = 0;
//	First fan button and slider
	JButton start1 = new JButton("Strat");
	JButton stop1 = new JButton("Stop");
	JButton reverse1 = new JButton("Reverse");
	JScrollBar speed1 =new JScrollBar(JScrollBar.HORIZONTAL,1,10,0,50);
//	Second fan button and slider
	JButton start2 = new JButton("Strat");
	JButton stop2 = new JButton("Stop");
	JButton reverse2 = new JButton("Reverse");
	JScrollBar speed2 =new JScrollBar(JScrollBar.HORIZONTAL,10,10,0,50);
//	Third fan button and slider
	JButton start3 = new JButton("Strat");
	JButton stop3 = new JButton("Stop");
	JButton reverse3 = new JButton("Reverse");
	JScrollBar speed3 =new JScrollBar(JScrollBar.HORIZONTAL,20,10,0,50);
//	Start all and end all
	JButton start = new JButton("Start All");
	JButton stop = new JButton("Stop All");
//	Three panel s
	FanPanel p1 = new FanPanel();
	FanPanel p2 = new FanPanel();
	FanPanel p3 = new FanPanel();
	
	public FanFrame() {
//		Set basic properties of Frame
		setTitle("Three-Fan");
		setBounds(200, 100, 915, 400);
		setVisible(true);
		setLayout(null);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		start.setBounds(300, 300, 100, 50);
		start.addActionListener(this);
		stop.setBounds(450, 300, 100, 50);
		stop.addActionListener(this);
		add(start);
		add(stop);
		
		
		p1.setLayout(null);	
		add(p1);
		p2.setLayout(null);
		add(p2);
		p3.setLayout(null);
		add(p3);
//		
		p1.setBounds(0, 0, 300, 300);
		p3.setBounds(600, 0, 300, 300);
		p2.setBounds(300, 0, 300, 300);
		
//		Set p1 button
		start1.setBounds(0, 0, 100, 30);
		start1.addActionListener(this);
		stop1.setBounds(100, 0, 100, 30);
		stop1.addActionListener(this);
		reverse1.setBounds(200, 0, 100, 30);
		reverse1.addActionListener(this);
		speed1.setBounds(0, 242, 300, 20);
		p1.x = speed1.getValue();
		speed1.addAdjustmentListener(this);
		
//		speed1.addAdjustmentListener(new AdjustmentListener() {
//			   public void adjustmentValueChanged(AdjustmentEvent e) {
//				   p1.c = e.getValue();
//			   }

//		Set p2 button
		start2.setBounds(0, 0, 100, 30);
		start2.addActionListener(this);
		stop2.setBounds(100, 0, 100, 30);
		stop2.addActionListener(this);
		reverse2.setBounds(200, 0, 100, 30);
		reverse2.addActionListener(this);
		speed2.setBounds(0, 242, 300, 20);
		p2.x = speed2.getValue();
		speed2.addAdjustmentListener(this);
		
//		Set p3 button
		start3.setBounds(0, 0, 100, 30);
		start3.addActionListener(this);
		stop3.setBounds(100, 0, 100, 30);
		stop3.addActionListener(this);
		reverse3.setBounds(200, 0, 100, 30);
		reverse3.addActionListener(this);
		speed3.setBounds(0, 242, 300, 20);
		p3.x = speed3.getValue();
		speed3.addAdjustmentListener(this);
		
		
//		Add p1 button
		p1.add(stop1);
		p1.add(start1);
		p1.add(reverse1);
		p1.add(speed1);
//		Add p2 button
		p2.add(stop2);
		p2.add(start2);
		p2.add(reverse2);
		p2.add(speed2);
//		Add p3 button
		p3.add(stop3);
		p3.add(start3);
		p3.add(reverse3);
		p3.add(speed3);
		
	}
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == start1) {
			flag_1 = true;
		}
		else if(e.getSource() == stop1) {
			flag_1 = false;
		}
		else if(e.getSource() == reverse1) {
			rev_1 = (rev_1 + 1) % 10;
		}
		else if(e.getSource() == start2) {
			flag_2 = true;
		}
		else if(e.getSource() == stop2) {
			flag_2 = false;
		}
		else if(e.getSource() == reverse2) {
			rev_2 = (rev_2 + 1) % 10;
		}
		else if(e.getSource() == start3) {
			flag_3 = true;
		}
		else if(e.getSource() == stop3) {
			flag_3 = false;
		}
		else if(e.getSource() == reverse3) {
			rev_3 = (rev_3 + 1) % 10;
		}
		else if(e.getSource() == start) {
			flag_1 = true;
			flag_2 = true;
			flag_3 = true;
		}
		else if(e.getSource() == stop) {
			flag_1 = false;
			flag_2 = false;
			flag_3 = false;
		}
	}
	public void adjustmentValueChanged(AdjustmentEvent e) {
		if ((JScrollBar) e.getSource() == speed1)
			p1.x = e.getValue();// e. The value obtained by getValue () is the same as scrollbar1 The value obtained by getValue () is the same.
		if ((JScrollBar) e.getSource() == speed2)
			p2.x = e.getValue();
		if ((JScrollBar) e.getSource() == speed3)
			p3.x = e.getValue();
	}


}

FanRun: process, call function to realize the operation of fan.

import java.util.concurrent.locks.*;
import javax.swing.*;

public class FanRun extends Thread{
	FanFrame f = new FanFrame();
	public FanRun() {
		run();
	}
	final Lock l = new ReentrantLock();
	public void run() {
		while(true) {
			l.lock();
			if(f.flag_1==false&&f.flag_2==false&&f.flag_3==false) {
				continue;
			}
			else if(f.flag_1==true&&f.flag_2==false&&f.flag_3==false) {
				f.p1.Rotate(1, f.rev_1);
			}
			else if(f.flag_1==false&&f.flag_2==true&&f.flag_3==false) {
				f.p2.Rotate(1, f.rev_2);
			}
			else if(f.flag_1==false&&f.flag_2==false&&f.flag_3==true) {
				f.p3.Rotate(1, f.rev_3);
			}
			else if(f.flag_1==true&&f.flag_2==true&&f.flag_3==false) {
				f.p1.Rotate(2, f.rev_1);
				f.p2.Rotate(2, f.rev_2);
			}
			else if(f.flag_1==true&&f.flag_2==false&&f.flag_3==true) {
				f.p1.Rotate(2, f.rev_1);
				f.p3.Rotate(2, f.rev_3);
			}
			else if(f.flag_1==false&&f.flag_2==true&&f.flag_3==true) {
				f.p3.Rotate(2, f.rev_3);
				f.p2.Rotate(2, f.rev_2);
			}
			else if(f.flag_1==true&&f.flag_2==true&&f.flag_3==true) {
				f.p1.Rotate(3, f.rev_1);
				f.p2.Rotate(3, f.rev_2);
				f.p3.Rotate(3, f.rev_3);
			}
			l.unlock(); 
		}
	}
	
}

FanMain: main function

package test7;

public class FanMain {
	public static void main(String[] args) {
		FanRun A = new FanRun();
		FanRun B = new FanRun();
		FanRun C = new FanRun();
		A.start();
		B.start();
		C.start();
	}
}

Keywords: Java

Added by stakes on Fri, 18 Feb 2022 21:25:27 +0200