Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; public class Time { int hour; int minute; int second; int time; int duration; int getHour() { Scanner getHour = new Scanner(System.in); System.out.println(Enter

import java.util.Scanner;

public class Time {

int hour;

int minute;

int second;

int time;

int duration;

int getHour() {

Scanner getHour = new Scanner(System.in);

System.out.println("Enter the time you are in:");

hour = getHour.nextInt();

if (hour >= 24)

System.out.println("You entered invalid time !");

return hour;

}

int getMinute() {

Scanner getMinute = new Scanner(System.in);

System.out.println("Enter the minute you are in:");

minute = getMinute.nextInt();

if (minute >= 60) {

System.out.println("You entered invalid minute !");

return -1;

} else

return minute;

}

void ShowHour(int hour, int minute) {

System.out.print(hour + ":" + minute);

}

}

import java.util.Scanner;

public class Sender extends Time {

String message, name, surname;

public void setWriteMessage() {

Scanner getMessage = new Scanner(System.in);

System.out.println("Enter the message:");

message = getMessage.nextLine();

if (message != null) {

this.message = message;

} else {

System.out.println("Message entered incorrectly !");

}

}

public String getWriteMessage() {

return message;

}

int messageSeenControl;

public void messageSeen() {

Scanner messageSeen = new Scanner(System.in);

System.out.println("If you read the message, press 1.");

messageSeenControl = messageSeen.nextInt();

if (messageSeenControl == 1)

System.out.println("Read.");

}

}

import java.util.Scanner;

public class Receiver extends Sender {

int messageSeenControl;

public void messageSeen() {

Scanner messageSeen = new Scanner(System.in);

System.out.println("If you read the message, press 1.");

messageSeenControl = messageSeen.nextInt();

if (messageSeenControl == 1)

System.out.println("Read.");

}

int permission;

public void isTherePermit() {

Scanner getPermission = new Scanner(System.in);

System.out.println("If you want to chat with this person, type 2.");

permission = getPermission.nextInt();

if (permission == 2)

System.out.println("The message may take a while.");

else

System.out

.println("It will not take a message without the opponent approval.");

}

}

import java.util.Scanner;

public class PermissionToMessage {

String permission;

public void isTherePermit() {

Scanner getPermission = new Scanner(System.in);

System.out.println("If you want to chat with this person, type 2.");

permission = getPermission.nextLine();

if (permission == "I certify")

System.out.println("The message may take a while.");

else

System.out

.println("It will not take a message without the opponent approval.");

}

}

public class Time2 {

int minute;

int hour;

void getHour(int hour, int minute) {

System.out.println(hour + ":" + minute);

}

}

import java.util.Date;

public class Test {

public static void main(String[] args) {

Sender g1 = new Sender();

g1.setWriteMessage();

g1.name = "AY?E";

g1.surname = "KARACA";

// g1.getMinute();

// g1.getHour();

System.out.println(g1.name + " " + g1.surname + " :"

+ g1.getWriteMessage() + " " + new Date().getHours() + ":"

+ new Date().getMinutes());

Receiver a1 = new Receiver();

a1.name = "B?RA";

a1.surname = "KARACA";

a1.messageSeen();

a1.isTherePermit();

a1.setWriteMessage();

// a1.getMinute();

// a1.getHour();

System.out.println(a1.name + " " + a1.surname + " :"

+ a1.getWriteMessage() + " " + new Date().getHours() + ":"

+ new Date().getMinutes());

if (a1.permission == 2) {

Sender g2 = new Sender();

g2.messageSeen();

g2.setWriteMessage();

g2.name = "BUSENUR";

g2.surname = "KARACA";

// g2.getMinute();

// g2.getHour();

System.out.println(g2.name + " " + g2.surname + " :"

+ g2.getWriteMessage() + " " + new Date().getHours() + ":"

+ new Date().getMinutes());

Receiver a2 = new Receiver();

a2.name = "B?RA";

a2.surname = "KARACA";

a2.messageSeen();

a2.setWriteMessage();

a2.getWriteMessage();

// a2.getHour();

System.out.println(a2.name + " " + a2.surname + " :"

+ a2.getWriteMessage() + " " + new Date().getHours() + ":"

+ new Date().getMinutes());

} else {

System.out.println("CHAT ?S TERM?NATED");

}

}

}

I created the messaging program in java, but i want to turn into actionlistener (button,label,jpanel etc), and if something is wrong or unnecessary that code, please fix , i will %100 thumbs up if it well :)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

Define and explain Zero-based Budgeting (ZBB).

Answered: 1 week ago