Posts

Showing posts from May, 2021

Game playing with number with computer in java

  package com.company ; import java.util.Scanner ; import java.util.Random ; class Game { int number ; int Inputnumber ; int NumberofGuesses = 0 ; public int getNumberofGuesses () { return NumberofGuesses ; } public void setNumberofGuesses ( int numberofGuesses ) { this . NumberofGuesses = numberofGuesses ; } Game () { Random rn = new Random (); this . number = rn . nextInt ( 100 ); } void takeUserInput () { System . out . println ( "enter your choice" ); Scanner sc = new Scanner ( System . in ); Inputnumber = sc . nextInt (); } boolean isCorrectNumber () { NumberofGuesses ++; if ( Inputnumber == number ) { System . out . format ( "yes you guessed it right, it was %d \n you get it in %d attempts " , number , NumberofGuesses ); return true ; } else if ( Inputnumber < number ) { System . out . p

tictaktoe game

  #include <bits/stdc++.h> using   namespace   std ; int   main (){      int   t ;  cin >> t ;      while ( t --){          char   a [ 3 ][ 3 ];  int   countx = 0 ,  counto = 0 ,  winx = 0 ,  wino = 0 ,  count_ = 0 ;          for ( int   i = 0 ;  i < 3 ;  i ++){              for ( int   j = 0 ;  j < 3 ;  j ++){                  cin >> a [ i ][ j ];                  if ( a [ i ][ j ]== 'X' )  countx ++;                  else   if ( a [ i ][ j ]== 'O' )  counto ++;   // taking input && counting their number                  else   if ( a [ i ][ j ]== '_' )  count_ ++;             }         }                     for ( int   i = 0 ;  i < 3 ;  i ++) {             if ( a [ i ][ 0 ]== a [ i ][ 1 ] &&  a [ i ][ 2 ]== a [ i ][ 1 ]){                if ( a [ i ][ 0 ]== 'X' )  winx ++;   // checking along the row                else   if ( a [ i ][ 0 ]== 'O' )  wino ++;           }       }         for ( int   i = 0

Game: Sciessor, Paper and Stone game in jave and it s source code is here

  package com.company ; import java.util.Scanner ; import java.util.Random ; public class rock_paper_scissors_game { public static void main (String[] args) { System. out .println( "before starting the game you should know this convention" ) ; System. out .println( "Scissor=0" ) ; System. out .println( "Paper=1" ) ; System. out .println( "Rock=2" ) ; short draw= 0 ; short yourCounter= 0 ; short compCounter= 0 ; for ( int i= 0 ; i< 3 ; i++) { Random rn = new Random() ; Scanner sc = new Scanner(System. in ) ; System. out .println( "ENTER YOUR CHOICE" ) ; byte choice = sc.nextByte() ; System. out .println( "CHOICE ENTERED BY COMPUTER" ) ; byte compRandom = ( byte ) rn.nextInt( 3 ) ; switch (choice) { case 0 : if (compRandom == 0 ) {

oops in c++ class

  #include   < iostream > #include   < sstream > using   namespace   std ; /* Enter code for class Student here. Read statement for specification. */ class   Student {      private :      int   age ,   standard ;      string   first_name ,   last_name ;           public :     void   set_age ( int   a ){ age = a ;}     void   set_standard ( int   s ){ standard = s ;}     void   set_first_name ( string   fname ){ first_name = fname ;}     void   set_last_name ( string   lname ){ last_name = lname ;}         int   get_age (){ return   age ;}     int   get_standard (){ return   standard ;}     string   get_first_name (){ return   first_name ;}     string   get_last_name (){ return   last_name ;}         string   to_string (){         stringstream   ss ;         ss << age << "," << first_name << "," << last_name << "," << standard ;         return   ss . str ();     }      }; int   main ()   {      int   age

Publish your website for free | fastest and quickest way

Image