nandomendoza 0 Newbie Poster

Would anyone be able to help me fill this code in. I have to ask the user for 2 playing cards. for example 7c(7 0f clubs). then at the end I have to compare the suit and print which card is the higher suit. I have the code outlined on what it should be. I just have a hard time with the code.

public class MyProgram2
{
	public void MyProgram2()
	{
		//declare variables
		String card1, card2;
		char rank1Char, rank2Char;
		char suit1, suit2;
		int rank1, rank2;


		//get the first card
		System.out.print("Please enter the first card: ");
		card1 = SavitchIn.readLine();


		//see if it is 2 characters long
		//use the length method
		if (  )
		{
			//get the first character of the string
			//use charAt method


			//determine the rank of the first character
			switch(rank1Char)
			{
				//set the value of the rank to an integer for compare later
				case '2': 	rank1 = 2;
									break;
				.
				.
				.
				.
				.

				default:		System.out.println("illegal card: " + card1);
									return;
			}

			//get the second character of the string to save the suit of the first card
			//use charAt method



			//check to see if it is a valid suit
			if (     )
			{
				System.out.println("illegal card: " + card1);
				return;
			}
		}
		//see if it is 3 characters long
		//use the length method
		else if (  )
		{
			//check to make sure it is a 1 and 0
			if (   )
				rank1 = 10;
			else
			{
				System.out.println("illegal card: " + card1);
				return;
			}
			//get the third character of the string to save the suit of the first card
			//use charAt method



			//check to see if it is a valid suit
			if (     )
			{
				System.out.println("illegal card: " + card1);
				return;
			}
		}
		else
		{
			System.out.println("illegal card: " + card1);
			return;
		}

		//get the second card
		System.out.print("Please enter the second card: ");
		card1 = SavitchIn.readLine();

		//see if it is 2 characters long
		//use the length method
		if (   )
		{

			//get the first character of the second card
			//use charAt method


			//determine the rank of the first character of the second card
			switch(rank2Char)
			{
				case '2': 	rank2 = 2;
									break;
				.
				.
				.
				.

				default:		System.out.println("illegal card: " + card2);
									return;
			}
			//get the second character of the second card to save the suit of the second card
			//use charAt method


			//check to see if it is a valid suit
			if (       )
			{
				System.out.println("illegal card: " + card2);
				return;
			}
		}
		//see if it is 3 characters long
		//use the length method
		else if (    )
		{
			//check to make sure it is a 1 and 0
			if (    )
				rank2 = 10;
			else
			{
				System.out.println("illegal card: " + card2);
				return;
			}
			//get the third character of the string to save the suit of the first card
			//use charAt method


			//check to see if it is a valid suit
			if (     )
			{
				System.out.println("illegal card: " + card2);
				return;
			}
		}
		else
		{
			System.out.println("illegal card: " + card2);
			return;
		}
		//check to see which rank is greater
		if (         )
			System.out.println("\n\n" + card1 + " is greater than " + card2);
		else if (       )
			System.out.println("\n\n" + card1 + " is less than " + card2);
		else
			System.out.println("\n\n" + card1 + " is equal to " + card2);
	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.