I usually use a framework when making marine-related products, but I felt that my ability to think about algorithms and basic skills was definitely weakened because of the convenience, so I also used it for self-improvement and reflection. I started making simple things.
A simple program that notifies you when you can catch fish
・ Check the current time to determine if it is a fishing time zone
・ The status is as follows 6: 00-8: 00 → Morning mazume (because phytoplankton rises to the surface for photosynthesis) 8: 00-17: 00 → Daytime (basic activity is sparse, sometimes you can catch) 17: 00-19: 00 → Evening Mazume (Large fish activate in search of small fish) 18: 00-6: 00 → Night (fish start moving. You can also aim for large fish)
mazumeAlert.java
import java.util.*;
import java.text.SimpleDateFormat;
class mazumeAlert {
public static void main(String[] args){
String display_result = "";
Calendar cTime = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("H");
int current_hour = Integer.parseInt(sdf.format(cTime.getTime()));
if(current_hour >= 6 && current_hour < 8){
display_result = OceanStatus.MORNING.getStatus();
}
if(current_hour >= 8 && current_hour < 17){
display_result = OceanStatus.NOON.getStatus();
}
if(current_hour >= 17 && current_hour < 19){
display_result = OceanStatus.SUNSET.getStatus();
}
if((current_hour >= 19 && current_hour <= 23)
|| (current_hour >= 0 && current_hour < 6)){
display_result = OceanStatus.NIGHT.getStatus();
}
System.out.println(display_result);
}
enum OceanStatus {
MORNING("Morning mazume:Time to catch"),
NOON("Daytime: Reasonable time zone"),
SUNSET("Evening Mazume: Fishing time"),
NIGHT("You can catch all night");
private final String status;
private OceanStatus(String status) {
this.status = status;
}
public String getStatus() {
return this.status;
}
}
}
It's not a big deal because it's a practice of looking back, but I would like to continue to accumulate logic that can be used steadily every day.
Recommended Posts