Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

Restaurant Application

Group 2

Names : -Muhartsal Raihan

-Hafizh Zaldy Alviansyah

Class : 4WD1

CEP CCIT

FAKULTAS TEKNIK UNIVERSITAS INDONESIA

2021
PROJECT ON

Restaurant Application

Developed by

1. Muhartsal Raihan
2. Hafizh Zaldy Alviansyah

2
Restaurant Application

Batch Code : -

Start Date : 16/04/2022


End Date : 20/04/2022

Name of Faculty : Indah Ayu

Names of Developer :

1. Muhartsal Raihan
2. Hafizh Zaldy Alviansyah

Date of Submission: 20/04/2022

3
CERTIFICATE

This is to certify that this report titled “ Restaurant Aplication “ embodies the original work
done by Muhartsal Raihan and Hafizh Zaldy Alviansyah. Project in partial fulfillment of
their course requirement at NIIT.

Coordinator:
Indah Ayu

4
ACKNOWLEDGEMENT

Praise and gratitude the author goes to the presence of God Almighty for His blessings and
grace, we were able to complete this project task both in the form of presentations and papers
on time.

The author also thanks Indah Ayu and other lecturers for all their guidance to complete it.
Thank you to fellow students who have supported, and also thank you to fellow education
staff at CCIT-FT UI. Project Paper entitled “Restaurant” which the author submitted as a
requirement for Project assignment in 2022.

Finally, the author hopes that this paper can be useful for all and also add a better insight into
the operating system. The author realizes that it is still not perfect. Therefore, the author
expects all suggestions and criticisms from readers that are constructive for the perfection of
this paper. Hopefully this paper can provide many benefits for readers.

5
System Analysis

System summary:

This program was created using Microsoft Visual Studio 2012 and uses the C #
programming language, this program is a restaurant menu that will be served.
At this restaurant we serve some food and drinks, there will always be a new menu from us.
In this program consists of several options, Input menu data, Display data menu, search data
menu, Edit menu data, and delete menu data.

Data from the menu that must be inputted by the user, including menu code, menu
name, category, price. the category is between food or drink. The data menu will be restored
in file text.

6
IMPLEMENTATION

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Restaurant
{
class Program
{
string idmenu, nmmenu, kategori;
int harga;
string isi;

public void isifile()


{
bacafile();
//object of filestream class is created
FileStream fs = new FileStream(@"D:\data.txt", FileMode.Append,
FileAccess.Write);
StreamWriter w = new StreamWriter(fs);

//prompting user to enter the string which needs to be stored in // the file
r Console.WriteLine("masukan id menu : ");
idmenu = Console.ReadLine();
Console.WriteLine("masukan nama menu : ");
nmmenu = Console.ReadLine();
Console.WriteLine("masukan nama kategori : ");
kategori = Console.ReadLine();
Console.WriteLine("masukan harga : ");
a harga = Convert.ToInt32(Console.ReadLine());

isi = idmenu + ":" + nmmenu + ":" + kategori + ":" + harga;

w.WriteLine(isi);
w.Flush();
w.Close();
fs.Close();
}

7
IMPLEMENTATION

public void bacafile()


{
string[] strArray = new string[4];
string str;

FileStream fs = new FileStream(@"D:\data.txt", FileMode.Open,


FileAccess.Read);
StreamReader sr = new StreamReader(fs);

sr.BaseStream.Seek(0, SeekOrigin.Begin);
System.Console.WriteLine("id nama kategori harga");
while ((str = sr.ReadLine()) != null)
{
int stringStartPos = str.IndexOf(':');
strArray = str.Split(new string[] { ":" }, StringSplitOptions.None);
for (int i = 0; i <= strArray.Length - 1; i++)
{
System.Console.Write(strArray[i] + "\t");
}
Console.WriteLine();
}
sr.Close();
fs.Close();
}

public void cariisifile()


{
string line, cari;
string[] strArray = new string[4];

Console.Write("input no id menu yang ingin dicari: ");


cari = Console.ReadLine();

System.IO.StreamReader file = new System.IO.StreamReader(@"D:\data.txt");


while ((line = file.ReadLine()) != null)
{
int stringStartPos = line.IndexOf(':');
if (cari.Equals(line.Substring(0, stringStartPos)))
{
strArray = line.Split(new string[] { ":" }, StringSplitOptions.None);
}
}

Console.WriteLine("DATA");
Console.WriteLine("id menu = " + strArray[0]);
Console.WriteLine("nama menu = " + strArray[1]);
Console.WriteLine("kategori = " + strArray[2]);
Console.WriteLine("harga = " + strArray[3]);
Console.WriteLine("------------------------------");
file.Close();

8
IMPLEMENTATION

file.Close();
}

public void hapusisifile()


{
string cari;
string strOldText;
string n = "";

System.Console.WriteLine("input no id menu yang ingin dicari : ");


cari = System.Console.ReadLine();

StreamReader sr = File.OpenText(@"D:\data.txt");
while ((strOldText = sr.ReadLine()) != null)
{
if (!strOldText.Contains(cari))
{
n += strOldText + Environment.NewLine;
}
}
sr.Close();
File.WriteAllText(@"D:\data.txt", n);
}

public void editdelimiter()


{
bacafile();
Console.Write("masukan id menu yang ingin diubah : ");
string target = Console.ReadLine();

FileStream fs = new FileStream(@"E:\data.txt", FileMode.Open,


FileAccess.Read);
StreamReader sr = new StreamReader(fs);

string line = sr.ReadLine();


string barisganti = "";
string newbaris = "";

while (line != null)


{
if (line.Contains(target))
{
barisganti = line;
string[] isi = line.Split(':');
Console.Clear();
newbaris = displaydata(isi, barisganti);
}
line = sr.ReadLine();
}
sr.Close();
fs.Close();

9
IMPLEMENTATION

replacefile(barisganti, newbaris);
Console.Clear();
Console.WriteLine("data berhasil diubah");
bacafile();
}

public string displaydata(string[] isi, string barisbaru)


{
Console.Clear();
Console.WriteLine("berikut data yang ingin diubah : ");
Console.WriteLine("--------------------------------");
Console.WriteLine("1.nama menu: " + isi[1]);
Console.WriteLine("2.harga : " + isi[3]);
Console.WriteLine("--------------------------------");
Console.Write("pilihan anda : ");
string pilih = Console.ReadLine();

string strSearch, strReplace, newdata = "";


switch (pilih)
{
case "1":
strSearch = isi[1];
Console.Write("masukan nama baru : ");
strReplace = Console.ReadLine();
newdata = isi[0] + ":" + strReplace + ":" + isi[2] + ":" + isi[3];
break;

case "2":
strSearch = isi[3];
Console.Write("masukan harga baru : ");
strReplace = Console.ReadLine();
newdata = isi[0] + ":" + isi[1] + ":" + isi[2] + ":" + strReplace;
break;
}
return newdata;
}

public void replacefile(string barisganti, string newbaris)


{
StreamReader sr = new StreamReader(@"D:\data.txt");
string content = sr.ReadToEnd();
sr.Close();

content = Regex.Replace(content, barisganti, newbaris);

StreamWriter sw = new StreamWriter(@"D:\data.txt");


sw.Write(content);
sw.Close();
}

10
IMPLEMENTATION

public void tampildata()


{
FileStream fs = new FileStream(@"D:\data.txt", FileMode.Open,
FileAccess.Read);
StreamReader sr = new StreamReader(fs);

string line = sr.ReadLine();

Console.WriteLine("berikut adalah seluruh data : ");


Console.WriteLine("--------------------------------");
Console.WriteLine("id\t|\tnama\t|\tkategori\t|\tharga\t");
while (line != null)
{
string[] isi = line.Split('#');
Console.WriteLine(" " + isi[0] + "\t|\t" + isi[1] + "\t|\t" + isi[2] + "\
t|\t" + isi[3]);
line = sr.ReadLine();
}
Console.WriteLine("-------------------------------");
sr.Close();
fs.Close();
}

static void Main(string[] args)


{
string pil;

string lagi = "y";


Program objAkses = new Program();
while (lagi == "Y" || lagi == "y")
{
Console.WriteLine("Daftar Data Menu Restaurant");
Console.WriteLine("1.input data menu");
Console.WriteLine("2.lihat data menu");
Console.WriteLine("3.cari data menu");
Console.WriteLine("4.ubah data menu");
Console.WriteLine("5.hapus data menu");
Console.Write("pilih[1-5] = ");
pil = Console.ReadLine();
switch (pil)
{
case "1":
objAkses.isifile();
Console.ReadLine();
break;

11
IMPLEMENTATION

case "2":
objAkses.bacafile();
Console.ReadLine();
break;
case "3":
objAkses.cariisifile();
Console.ReadLine();
break;
case "4":
objAkses.editdelimiter();
Console.ReadLine();
break;
case "5":
objAkses.hapusisifile();
Console.ReadLine();
break;
}
Console.WriteLine("kembali ke menu[Y/T]?");
lagi = Console.ReadLine();
}
}
}
}

12
INTERFACE DESIGN FOR RESTAURANT
APPLICATION

Input Data Menu

13
INTERFACE DESIGN FOR RESTAURANT
APPLICATION
Lihat Data Menu

14
INTERFACE DESIGN FOR RESTAURANT
APPLICATION
Cari Data Menu

15
INTERFACE DESIGN FOR RESTAURANT
APPLICATION
Ubah Data Menu

16
INTERFACE DESIGN FOR RESTAURANT
APPLICATION
Hapus Data Menu

17
CONFIGURATION

Hardware: MSI i7-2600 CPU 3,40 GHz, Nvidia Geforce GTX 750 Ti, Ram 8 GB

Operating System: Windows 10

Software: Microsoft Visual Studio 2012

PROJECT FILE DETAILS


S.No File Name Remarks
MAKALAH Restaurant.doc

18

You might also like