Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.8 kB
4
Indexable
Never
private static void getStandardDelayOfReplyByPeriod(String member_name, int start_id, int end_id) {
		boolean foundMemberName = false;
		Member member = initMember;
		for (Member m : members) {
			if (m.getName() == member_name) {
				foundMemberName = true;
				member = m;
			}
		}

		// handle errors

		if (foundMemberName == false) {
			java.lang.System.out.println("Member " + member_name + " does not exist");
			return;
		}	

		if (member.getMemberType() != "administrator") {
			java.lang.System.out.println("Only administrators can get standard delay of reply");
			return;
		}

		if (end_id < start_id || start_id < 0 || start_id >= member.countTransactionsSent() || end_id >= member.countTransactionsSent()) {
			java.lang.System.out.println("Illegal period");
			return;
		}

		double average_delay = member.countSumDelay() / (end_id - start_id + 1);
		java.lang.System.out.println("%.2f", "Average delay: " + average_delay);
	}

	private static void getPercentageOfUnsuccessfulTransaction(String member_name) {
		boolean foundMemberName = false;
		Member member = initMember;
		for (Member m : members) {
			if (m.getName() == member_name) {
				foundMemberName = true;
				member = m;
			}
		}

		// handle errors

		if (foundMemberName == false) {
			java.lang.System.out.println("Member " + member_name + " does not exist");
			return;
		}	

		if (member.getMemberType() != "administrator") {
			java.lang.System.out.println("Only administrators can get standard delay of reply");
			return;
		}

		int success = 0;
		for (Transaction t : member.sentTransactions) {
			if (t.isDelayed() == false) {
				success += 1;
			}
		}
		double percentage = (double) success / member.countTransactionsSent();
		java.lang.System.out.println("%.2f", "PercentageOfUnsuccessfulTransaction: " + percentage + "%");
	}
Leave a Comment