JAVA関連のことを調べてみた2021年09月29日

JAVA関連のことを調べてみた2021年09月29日

【Java】カプセル化の理解ついての復習をしていく

#目的

* カプセル化に関しての復習と定着

#実際の手順と実例
###1.カプセル化とは

* カプセル化とはオブジェクトの情報をカプセルのようにまとめ、中身を隠蔽したままオブジェクトを利用すること
* カプセル化のイメージは
* 外から防御されている
* カプセルに包まれている
* 「オブジェクト内のデータ」を包み、「オブジェクト外からの不正アクセス」を防ぐ

これらのイメージを持って問題を例にして考えていきます。

###2.例題

####問題

「Practice.java」を実行した結果が同じになるように、「NoCapsule.java」を「Capsule.java」に変更して、カプセル化したプログラムに変更してください。

**実行結果**

““`java
好きな食べ物はラーメンです。
週に1回食べています。
最近は週に2回食べるようになりました。。。
““`

““`NoCapsule.java
package practice;

public class NoCapsule {
public String food;

元記事を表示

【Minecraft Development】 Spigotプラグイン開発 最初の設定チートシート

# はじめに

このQiitaは **IntelliJ IDEA のプラグイン “Minecraft Development”** を使っている人向けの記事です。

VScodeなどで開発している人向けではないこと、それから自分向けの備忘録でもあります。

しっかりとした説明は省きます。

## まずやること

* IntelliJ IDEAに Minecraft Development を導入する
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/666481/8370d6a8-cf26-c9b8-12f5-91190408ecfb.png)
* JDKを導入する
* Minecraft v1.17以前のプロジェクトを開発するときは **JDK v1.8**
* Minecraft v1.17以降のプロジェクトを開発するときは **JDK v16**
* それぞれ変えないと開発できないので注意
* [JDKのダウンロードはこちらから](https://w

元記事を表示

Java Word文書からPDFに変換

Spire.Doc for Javaを利用することで、Wordファイルから、ただ数秒で様々なファイルに変換できます。これこそが、Javaでプログラミングを行う開発者にとって、とても使いやすいライブラリじゃないでしょうか。さあ、今回は、Word文書からPDFに変換する方法を紹介していきましょう!簡単なので、もしお役に立てば嬉しいと思います。

Spire.Doc for Javaとは?

Spire. Doc for Javaは、E-iceblue社が開発され、開発者が JavaプラットホームでWordのドキュメントを迅速か

[100%] CountSemiprimes

_Lesson11_
## [Sieve of Eratosthenes](https://app.codility.com/programmers/lessons/11-sieve_of_eratosthenes/)

[Open reading material (PDF)](https://codility.com/media/train/9-Sieve.pdf)

> _Medium_
> ### [CountSemiprimes](https://app.codility.com/programmers/lessons/11-sieve_of_eratosthenes/count_semiprimes/)
> Count the semiprime numbers in the given range [a..b]

#### Task description

A prime is a positive integer X that has exactly two distinct divisors: 1 and X. The first few prime integer

[100%] CountNonDivisible

_Lesson11_
## [Sieve of Eratosthenes](https://app.codility.com/programmers/lessons/11-sieve_of_eratosthenes/)

[Open reading material (PDF)](https://codility.com/media/train/9-Sieve.pdf)

> _Medium_
> ### [CountNonDivisible](https://app.codility.com/programmers/lessons/11-sieve_of_eratosthenes/count_non_divisible/)
> Calculate the number of elements of an array that are not divisors of each element.

#### Task description

You are given an array A consisting of N integers.

For each number A[i]

[100%] Peaks

_Lesson10_
## [Prime and composite numbers](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/)

[Open reading material (PDF)](https://codility.com/media/train/8-PrimeNumbers.pdf)

> _Medium_
> ### [Peaks](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/peaks/)
> Divide an array into the maximum number of same-sized blocks, each of which should contain an index P such that A[P – 1] < A[P] > A[P + 1].

### Task description

A non-empty array A

[100%] Flags

_Lesson10_
## [Prime and composite numbers](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/)

[Open reading material (PDF)](https://codility.com/media/train/8-PrimeNumbers.pdf)

> _Medium_
> ### [Flags](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/flags/)
> Find the maximum number of flags that can be set on mountain peaks.

#### Task description

A non-empty array A consisting of N integers is given.

A peak is an array element which i

[100%] MinPerimeterRectangle

_Lesson10_
## [Prime and composite numbers](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/)

[Open reading material (PDF)](https://codility.com/media/train/8-PrimeNumbers.pdf)

> _Easy_
> ### [MinPerimeterRectangle](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/min_perimeter_rectangle/)
> Find the minimal perimeter of any rectangle whose area equals N.

#### Task description

An integer N is given, representing the area of some rectang

[100%] CountFactors

_Lesson10_
## [Prime and composite numbers](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/)

[Open reading material (PDF)](https://codility.com/media/train/8-PrimeNumbers.pdf)

> _Easy_
> ### [CountFactors](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/count_factors/)
> Count factors of given number n.

#### Task description

A positive integer D is a factor of a positive integer N if there exists an integer M such that N = D * M.

For

[100%] MaxDoubleSliceSum

_Lesson9_
## [Maximum slice problem](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/)

[Open reading material (PDF)](https://codility.com/media/train/7-MaxSlice.pdf)

> _Medium_
> ### [MaxDoubleSliceSum](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/max_double_slice_sum/)
> Find the maximal sum of any double slice.

#### Task description

A non-empty array A consisting of N integers is given.

A triplet (X, Y, Z), such that 0 ≤ X < Y < Z < N, is calle

[100%] MaxSliceSum

_Lesson9_
## [Maximum slice problem](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/)

[Open reading material (PDF)](https://codility.com/media/train/7-MaxSlice.pdf)

> _Easy_
> ### [MaxSliceSum](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/max_slice_sum/)
> Find a maximum sum of a compact subsequence of array elements.

#### Task description

A non-empty array A consisting of N integers is given. A pair of integers (P, Q), such that 0 ≤ P ≤ Q < N, i

[100%] MaxProfit

_Lesson9_
## [Maximum slice problem](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/)

[Open reading material (PDF)](https://codility.com/media/train/7-MaxSlice.pdf)

> _Easy_
> ### [MaxProfit](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/max_profit/)
> Given a log of stock prices compute the maximum possible earning.

#### Task description

An array A consisting of N integers is given. It contains daily prices of a stock share for a period of N cons

[100%] EquiLeader

_Lesson8_
## [Leader](https://app.codility.com/programmers/lessons/8-leader/)

[Open reading material (PDF)](https://codility.com/media/train/6-Leader.pdf)

> _Easy_
> ### [EquiLeader](https://app.codility.com/programmers/lessons/8-leader/equi_leader/)
> Find the index S such that the leaders of the sequences A[0], A[1], …, A[S] and A[S + 1], A[S + 2], …, A[N – 1] are the same.

#### Task description

A non-empty array A consisting of N integers is given.

The leader of this array is the val

[100%] Dominator

_Lesson8_
## [Leader](https://app.codility.com/programmers/lessons/8-leader/)

[Open reading material (PDF)](https://codility.com/media/train/6-Leader.pdf)

> _Easy_
> ### [Dominator](https://app.codility.com/programmers/lessons/8-leader/dominator/)
> Find an index of an array such that its value occurs at more than half of indices in the array.

#### Task description
***
An array A consisting of N integers is given. The dominator of array A is the value that occurs in more than half of the elem

[100%] StoneWall

_Lesson7_
## [Stacks and Queues](https://app.codility.com/programmers/lessons/7-stacks_and_queues/)

[Open reading material (PDF)](https://codility.com/media/train/5-Stacks.pdf)

> _Easy_
> ### [StoneWall](https://app.codility.com/programmers/lessons/7-stacks_and_queues/stone_wall/)
> Cover “Manhattan skyline” using the minimum number of rectangles.

#### Task description
***

You are going to build a stone wall. The wall should be straight and N meters long, and its thickness should be constan

[100%] Nesting

_Lesson7_
## [Stacks and Queues](https://app.codility.com/programmers/lessons/7-stacks_and_queues/)

[Open reading material (PDF)](https://codility.com/media/train/5-Stacks.pdf)

> _Easy_
> ### [Nesting](https://app.codility.com/programmers/lessons/7-stacks_and_queues/nesting/)
> Determine whether a given string of parentheses (single type) is properly nested.

#### Task description
***
A string S consisting of N characters is called properly nested if:

* S is empty;
* S has the form “(U)” wh

[100%] Fish

_Lesson7_

## [Stacks and Queues](https://app.codility.com/programmers/lessons/7-stacks_and_queues/)

[Open reading material (PDF)](https://codility.com/media/train/5-Stacks.pdf)

> _Easy_
> ### [Fish](https://app.codility.com/programmers/lessons/7-stacks_and_queues/fish/)
> N voracious fish are moving along a river. Calculate how many fish are alive.

#### Task description
***
You are given two non-empty arrays A and B consisting of N integers. Arrays A and B represent N voracious fish in a ri

[100%] Brackets

_Lesson7_

## [Stacks and Queues](https://app.codility.com/programmers/lessons/7-stacks_and_queues/)

[Open reading material (PDF)](https://codility.com/media/train/5-Stacks.pdf)

> _Easy_
> ### [Brackets](https://app.codility.com/programmers/lessons/7-stacks_and_queues/brackets/)
> Determine whether a given string of parentheses (multiple types) is properly nested.

#### Task description
***
A string S consisting of N characters is considered to be properly nested if any of the following condit

[100%] Triangle

_Lesson6_
## [Sorting](https://app.codility.com/programmers/lessons/6-sorting/)

[Open reading material (PDF)](https://codility.com/media/train/4-Sorting.pdf)

> _Easy_
> ### [Triangle](https://app.codility.com/programmers/lessons/6-sorting/triangle/)
> Determine whether a triangle can be built from a given set of edges.

#### Task description
***
An array A consisting of N integers is given. A triplet (P, Q, R) is triangular if 0 ≤ P < Q < R < N and: * A[P] + A[Q] > A[R],
* A[Q] + A[R] > A[P],

[100%] Number of discIntersections

> _Medium_
> ### [NumberOfDiscIntersections](https://app.codility.com/programmers/lessons/6-sorting/number_of_disc_intersections/)
> Compute the number of intersections in a sequence of discs.

#### Task description
***
We draw N discs on a plane. The discs are numbered from 0 to N − 1. An array A of N non-negative integers, specifying the radiuses of the discs, is given. The J-th disc is drawn with its center at (J, 0) and radius A[J].

We say that the J-th disc and K-th disc intersect if J ≠ K