Ada yang tertarik diskusi programming?

Page 6 of 6 Previous  1, 2, 3, 4, 5, 6

View previous topic View next topic Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by Sheratan on Mon Apr 04, 2011 9:03 pm

kondisi passwordnya udah jalan:
Code:
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <string>
//Zeus Class Project

using namespace std;

void gotoxy(int x, int y)
{
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

int main()
{
    char name[15],pass[15];
    string a="oke",b="241";
    int i;
    system("cls");
    gotoxy(20,5);
    cout<<"--ZEUS CLASS PROJECT--\n";
    gotoxy(20,6);
    cout<<"Username: ";
    cin>>name;
    gotoxy(20,7);
    cout<<"Password: ";
    cin>>pass;
        {
            if ( (name==a) && (pass==b) )
            cout<<"\nBenar";
            else
            cout<<"\nUSERNAME atau PASSWORD SALAH";
        }
        return 0;
    getch();
}

sekarang cara masukin maskingnya ke dalam program utamanya...

Itu library Allegro: http://alleg.sourceforge.net/ pernah coba?

Atau OGRE: http://www.ogre3d.org/tikiwiki/Codeblocks

oe kurang 1 lagi sih programnya sebernenya, masih dibuat...

Sheratan
Sensei
Sensei

Troll hunter, Mod hater.

Male Race : Pervert

Posts : 1848
Gold : 5444
Reputation : 6
Join date : 2010-06-21
Age : 18
Location : Behind my troll-jet.

View user profile

Back to top Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by yokaroumon on Tue Apr 05, 2011 3:22 pm

Sheratan wrote:kondisi passwordnya udah jalan:
Code:
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <string>
//Zeus Class Project

using namespace std;

void gotoxy(int x, int y)
{
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

int main()
{
    char name[15],pass[15];
    string a="oke",b="241";
    int i;
    system("cls");
    gotoxy(20,5);
    cout<<"--ZEUS CLASS PROJECT--\n";
    gotoxy(20,6);
    cout<<"Username: ";
    cin>>name;
    gotoxy(20,7);
    cout<<"Password: ";
    cin>>pass;
        {
            if ( (name==a) && (pass==b) )
            cout<<"\nBenar";
            else
            cout<<"\nUSERNAME atau PASSWORD SALAH";
        }
        return 0;
    getch();
}

sekarang cara masukin maskingnya ke dalam program utamanya...

Itu library Allegro: http://alleg.sourceforge.net/ pernah coba?

Atau OGRE: http://www.ogre3d.org/tikiwiki/Codeblocks

oe kurang 1 lagi sih programnya sebernenya, masih dibuat...
jadinya nggak jadi pakai "*"? Ara?
Spoiler:

Code:

// hanya bisa di console
#include <iostream>
#include <stdexcept>
#include <string>
#include <windows.h>

std::string getpassword(){
    std::string result;

    DWORD mode, count;
    HANDLE ih = GetStdHandle(STD_INPUT_HANDLE);
    HANDLE oh = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleMode(ih, &mode);
    SetConsoleMode(ih, mode & ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT));

    char c;
    while(ReadConsoleA(ih, &c, 1, &count, NULL) && (c != '\r') && (c != '\n')){
        if(c == '\b'){
            if(result.length()){
                WriteConsoleA(oh, "\b \b", 3, &count, NULL);
                result.erase(result.end()-1);
            }
        }
        else{
            WriteConsoleA(oh, "*", 1, &count, NULL);
            result.push_back(c);
        }
    }

    SetConsoleMode(ih, mode);
    return result;
}
int main(){
    std::cout<<"masukkan password : ";
    std::string password = getpassword();
    std::cout<<"\nPassword : "<<password<<'\n';

    return 0;
}

masukin ke dalam program utamanya? Ara?
kayak gini?
Spoiler:

Code:

#include <iostream>
#include <string>
bool mypass(){
    std::string a;
    std::cout<<"masukkan password : ";
    std::cin>>a;
    return (a=="pass");
}
int main(){
    while(!mypass()) std::cout<<"password salah\n";
    std::cout<<"password benar\n\nmasuk ke program utama\n";
    return 0;
}

belum pernah pakai allegro ataupun OGRE Ocha

yokaroumon
Sensei
Sensei

Male Race : Genius Freak
No Medal
Posts : 2993
Gold : 6843
Reputation : 10
Join date : 2010-06-09

View user profile

Back to top Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by Sheratan on Tue Apr 05, 2011 7:25 pm

Bukan bukan, kondisi passwordnya sudah jalan. Hanya saja pas dicoba memasukkan masking password (****) gak jalan.

Ini saya dapat hasil googling masking:
Code:
#include <stdio.h>
#include <conio.h>
main()
{
    char password[32];
    int i;
    printf("Masukkan Password \t=");
    for(i=0;i<32;i++)
    {
        password[i]=getch();
        if(password[i]=='\r')
        {
            password[i]=0;
            break;
        }
        if(password[i]=='\n')
        {
            if(i!=0)printf("\b\b");
            password[i]=0;
            password[i-1]=0;
            i-=2;
            if(i<-1)i=-1;
            continue;
        }
        printf("*");
    }
    getch();
}
nah bingungnya itu, gimana masukin koding diatas agar jalan sama koding kondisi password yang ini:
Code:
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <string>
//Zeus Class Project

using namespace std;

void gotoxy(int x, int y)
{
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

int main()
{
    char name[15],pass[15];
    string a="oke",b="241";
    int i;
    system("cls");
    gotoxy(20,5);
    cout<<"--ZEUS CLASS PROJECT--\n";
    gotoxy(20,6);
    cout<<"Username: ";
    cin>>name;
    gotoxy(20,7);
    cout<<"Password: ";
    cin>>pass;
        {
            if ( (name==a) && (pass==b) )
            cout<<"\nBenar";
            else
            cout<<"\nUSERNAME atau PASSWORD SALAH";
        }
        return 0;
    getch();
}

tapi saya coba dulu koding dari bung yoka yg pertama, yg //hanya bisa di konsol deh!

Sheratan
Sensei
Sensei

Troll hunter, Mod hater.

Male Race : Pervert

Posts : 1848
Gold : 5444
Reputation : 6
Join date : 2010-06-21
Age : 18
Location : Behind my troll-jet.

View user profile

Back to top Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by yokaroumon on Thu Apr 07, 2011 6:29 pm

Sheratan wrote:Bukan bukan, kondisi passwordnya sudah jalan. Hanya saja pas dicoba memasukkan masking password (****) gak jalan.

Ini saya dapat hasil googling masking:
Code:
#include <stdio.h>
#include <conio.h>
main()
{
    char password[32];
    int i;
    printf("Masukkan Password \t=");
    for(i=0;i<32;i++)
    {
        password[i]=getch();
        if(password[i]=='\r')
        {
            password[i]=0;
            break;
        }
        if(password[i]=='\n')
        {
            if(i!=0)printf("\b\b");
            password[i]=0;
            password[i-1]=0;
            i-=2;
            if(i<-1)i=-1;
            continue;
        }
        printf("*");
    }
    getch();
}
saya coba nggak jalan Facedesk

yokaroumon
Sensei
Sensei

Male Race : Genius Freak
No Medal
Posts : 2993
Gold : 6843
Reputation : 10
Join date : 2010-06-09

View user profile

Back to top Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by Sheratan on Fri Apr 08, 2011 1:34 pm

Saya jalan... Sweat

Yang kondisi+masking udah jalan setelah dikutak-katik sama temen saya, tapi dia belum ngirim gimana kodingnya. Tunggu... tunggu... Pray

Sekarang iseng mau buat progam menghitun rekening listrik secara sederhana aahh... Waai

Sheratan
Sensei
Sensei

Troll hunter, Mod hater.

Male Race : Pervert

Posts : 1848
Gold : 5444
Reputation : 6
Join date : 2010-06-21
Age : 18
Location : Behind my troll-jet.

View user profile

Back to top Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by Sheratan on Sun Apr 10, 2011 8:41 pm

Oke Project ke-2 sudah hampir selesai...
Code:


#include <iostream>
#include <fstream>
#include <cstdlib>
#include <conio.h>
#include <windows.h>
#include <ctime>
#include <dos.h>
#include <stdio.h>
//Program Penghitung Rekening Listrik Sederhana
//Copyright © 2011  Andi, Rifka, Ida Bagus

//To do list:
//1. "Input salah" dan kembali ke menu, bukan keluar.
//2. Hasil inputan tidak tertimpa, tapi tercetak ke baris baru.
//3. Dapat membandingkan setiap data yang ada di hasil.txt dan mencari selisihnya

using namespace std;
int blok_1,blok_2,blok_3,volt,blok_total,i,pilihan,pil,pil2;
double totalbia_blok,total_tagihan,tvolt;

void gotoxy(int x, int y)
{
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

void delay(unsigned long ms)
{
    clock_t start = clock();
    while(clock() - start < ms);
}

void tampilan()
{
    gotoxy(15,6);cout<<"---------------------------------------------";
    gotoxy(15,8);cout<<"---------------------------------------------";
    gotoxy(15,9);cout<<"|";
    gotoxy(59,9);cout<<"|";
    gotoxy(59,10);cout<<"|";
    gotoxy(59,11);cout<<"|";
    gotoxy(59,12);cout<<"|";
    gotoxy(15,9);cout<<"|";
    gotoxy(15,10);cout<<"|";
    gotoxy(15,11);cout<<"|";
    gotoxy(15,12);cout<<"|";
    gotoxy(15,13);cout<<"---------------------------------------------";
}

void tampilan2()
{
    gotoxy(15,6);cout<<"---------------------------------------------";
    gotoxy(15,8);cout<<"---------------------------------------------";
    gotoxy(25,9);cout<<"|";
    gotoxy(59,9);cout<<"|";
    gotoxy(59,10);cout<<"|";
    gotoxy(59,11);cout<<"|";
    gotoxy(59,12);cout<<"|";
    gotoxy(15,9);cout<<"|";
    gotoxy(15,10);cout<<"|";
    gotoxy(15,11);cout<<"|";
    gotoxy(15,12);cout<<"|";
    gotoxy(15,13);cout<<"---------------------------------------------";
}

void tampilan3()
{
    system("cls");
    gotoxy(30,5);
    delay(200);cout<<"T";
    delay(200);cout<<"E";
    delay(200);cout<<"R";
    delay(200);cout<<"I";
    delay(200);cout<<"M";
    delay(200);cout<<"A";
    delay(200);cout<<" ";
    delay(200);cout<<"K";
    delay(200);cout<<"A";
    delay(200);cout<<"S";
    delay(200);cout<<"I";
    delay(200);cout<<"H";
}

void perhitungan()
{
    double tblok_1,tblok_2,tblok_3;
    tblok_1=blok_1*159;
    tblok_2=blok_2*250;
    tblok_3=blok_3*278;
    totalbia_blok=tblok_1+tblok_2+tblok_3;
    tvolt=(volt*0.001)*11364;
    total_tagihan=totalbia_blok+tvolt;
    blok_total=blok_1+blok_2+blok_3;
}

void output()
{
    system("cls");
    gotoxy(30,10);
    cout<<"LOADING";
    for(i=1;i<=5;i++)
    {
        delay(500);
        cout<<".";
    }
    system("cls");
    tampilan2();
    gotoxy(26,7);
    cout<<"Biaya Pemakaian total";
    gotoxy(16,9);cout<<" Pemakaian (KWh): "<<blok_total;
    gotoxy(16,10);cout<<" Biaya Beban: Rp "<<tvolt;
    gotoxy(16,11);cout<<" Biaya Pemakaian: Rp "<<totalbia_blok;
    gotoxy(16,12);cout<<" Jumlah Tagihan: Rp "<<total_tagihan;
}

int simpan()//tambah data
{
    ofstream output;
    output.open("C:/hasil.txt",ios::app);
    if(!output)
    {
        cout<<"File tidak dapat dibuka"<<endl;
        return 1;
    }
    output<<"Pemakaian: "<<blok_total<<endl;
    output<<"Biaya Beban: "<<tvolt<<endl;
    output<<"Biaya Pemakaian: "<<totalbia_blok<<endl;
    output<<"Jumlah Tagihan: "<<total_tagihan<<endl;
    output.close();
    return 0;
}

int database()//lihat data
{
    ifstream input;
    input.open("C:/hasil.txt",ios::app);
    if(!input)
    {
        cout<<"File tidak dapat dibuka"<<endl;
        return 1;
    }
    char a[10];
    input>>a;
    tampilan();
    gotoxy(49,7);cout<<"=DATABASE=";
    gotoxy(16,9);cout<<"Pemakaian (KWh): "<<blok_total<<endl;
    gotoxy(16,10);cout<<"Biaya Beban: Rp "<<tvolt<<endl;
    gotoxy(16,11);cout<<"Biaya Pemakaian: Rp "<<totalbia_blok<<endl;
    gotoxy(16,12);cout<<"Jumlah Tagihan: Rp "<<total_tagihan<<endl;
    input.close();
    getch();
    return 0;
}

void terminal()
{
    system("cls");
    tampilan();
    gotoxy(15,7);cout<<"Program Penghitung Rekening Listrik Sederhana";
    gotoxy(16,9);cout<<" Masukkan daya (VA): ";
    cin>>volt;
    gotoxy(16,10);cout<<" Masukkan biaya pemakaian Blok I: ";
    cin>>blok_1;
    gotoxy(16,11);cout<<" Masukkan biaya pemakaian Blok II: ";
    cin>>blok_2;
    gotoxy(16,12);cout<<" Masukkan biaya pemakaian Blok III: ";
    cin>>blok_3;
    perhitungan();
    output();
    simpan();
    getch();
    gotoxy(15,14);cout<<"Apakah yang ingin anda lakukan? ";
    gotoxy(15,15);cout<<"1. Cek Database";
    gotoxy(15,16);cout<<"2. Mengulang Perhitungan";
    gotoxy(15,17);cout<<"3. Keluar";
    gotoxy(15,18);cout<<"Pilihan:"; cin>>pil;
    switch (pil)
    {
        case 1:
        system("cls");
        database();
        gotoxy(15,14);cout<<"Apakah yang ingin anda lakukan? "<<endl;
        gotoxy(15,15);cout<<"1. Mengulang Perhitungan"<<endl;
        gotoxy(15,16);cout<<"2. Keluar"<<endl;
        gotoxy(15,17);cout<<"Pilihan: ";
        cin>>pil2;
        switch (pil2)
        {
            case 1:
            terminal();
            break;
            case 2:
            tampilan3();
            break;
            default:
            cout<<"Input Salah";
            break;
        }
        getch();
        break;
        case 2:
        terminal();
        break;
        case 3:
        tampilan3();
        break;
    }
}

int main()
{
    tampilan();
    gotoxy(49,7);cout<<"=TERMINAL=";
    gotoxy(16,9);cout<<"1. Cek Database"<<endl;
    gotoxy(16,10);cout<<"2. Memasukkan inputan"<<endl;
    gotoxy(16,11);cout<<"3. Keluar"<<endl;
    gotoxy(16,12);cout<<"Pilihan: ";
    cin>>pilihan;
    switch (pilihan)
    {
        case 1:
        system ("cls");
        database();
        getch();
        gotoxy(15,14);cout<<"Apakah yang ingin anda lakukan? "<<endl;
        gotoxy(15,15);cout<<"1. Mengulang Perhitungan"<<endl;
        gotoxy(15,16);cout<<"2. Keluar"<<endl;
        gotoxy(15,17);cout<<"Pilihan: ";
        cin>>pil2;
        switch (pil2)
        {
            case 1:
            terminal();
            break;
            case 2:
            tampilan3();
            break;
            default:
            gotoxy(15,19);cout<<"Input Salah";
            break;
        }
    }
}
Sedikit bantuan pada to-do list?

Sheratan
Sensei
Sensei

Troll hunter, Mod hater.

Male Race : Pervert

Posts : 1848
Gold : 5444
Reputation : 6
Join date : 2010-06-21
Age : 18
Location : Behind my troll-jet.

View user profile

Back to top Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by yokaroumon on Sat Apr 16, 2011 7:25 pm

Sheratan wrote:Oke Project ke-2 sudah hampir selesai...
Code:
//To do list:
//1. "Input salah" dan kembali ke menu, bukan keluar.
//2. Hasil inputan tidak tertimpa, tapi tercetak ke baris baru.
//3. Dapat membandingkan setiap data yang ada di hasil.txt dan mencari selisihnya
Sedikit bantuan pada to-do list?
1. pakai while (atau for), selesai
2. maksudnya? pakai gotoxy mungkin Ara?
3. kayak gini maksudnya? Ara?
for data in hasil:
selisih[i] = data - prev_data
prev_data = data
i += 1

yokaroumon
Sensei
Sensei

Male Race : Genius Freak
No Medal
Posts : 2993
Gold : 6843
Reputation : 10
Join date : 2010-06-09

View user profile

Back to top Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by Sheratan on Sun Apr 17, 2011 11:39 am

1. Selesai.
2. Bukan, kan hasil perhitungan dicetak ke dalam file hasil.txt, nah setiap inputan baru dimasukkan saya inginnya inputan tersebut tidak menimpa inputan sebelumnya yg ada di file tersebut. Begitu...

3. Belum dicoba.

Sheratan
Sensei
Sensei

Troll hunter, Mod hater.

Male Race : Pervert

Posts : 1848
Gold : 5444
Reputation : 6
Join date : 2010-06-21
Age : 18
Location : Behind my troll-jet.

View user profile

Back to top Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by Sheratan on Mon Apr 25, 2011 10:16 am

Karena eh karena teman-teman saya di forum sebelah bersama saya iseng-iseng membuat VN berbasis piton, bijimana kalau kita belajar piton? Megane

Sheratan
Sensei
Sensei

Troll hunter, Mod hater.

Male Race : Pervert

Posts : 1848
Gold : 5444
Reputation : 6
Join date : 2010-06-21
Age : 18
Location : Behind my troll-jet.

View user profile

Back to top Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by yokaroumon on Tue Apr 26, 2011 5:29 pm

Sheratan wrote:Karena eh karena teman-teman saya di forum sebelah bersama saya iseng-iseng membuat VN berbasis piton, bijimana kalau kita belajar piton? Megane

python ya? bahasa kedua saya tuh setelah C++ Blush Khukhukhu
bikin VN berbasis python? renpy? Ara?

yokaroumon
Sensei
Sensei

Male Race : Genius Freak
No Medal
Posts : 2993
Gold : 6843
Reputation : 10
Join date : 2010-06-09

View user profile

Back to top Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by Sheratan on Fri Apr 29, 2011 8:53 pm

Yup. RenPy. Yg mudah2 dulu kita...

Wah bisa ternyata dikau hore~

Sheratan
Sensei
Sensei

Troll hunter, Mod hater.

Male Race : Pervert

Posts : 1848
Gold : 5444
Reputation : 6
Join date : 2010-06-21
Age : 18
Location : Behind my troll-jet.

View user profile

Back to top Go down

Solved Re: Ada yang tertarik diskusi programming?

Post by Sponsored content Today at 11:22 pm


Sponsored content


Back to top Go down

Page 6 of 6 Previous  1, 2, 3, 4, 5, 6

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum