Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions cuisine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef CUISINE_H
#define CUISINE_H
#include<iostream>
#include<string>
using namespace std;

class cuisine{
private:
int num_of_dishes;
std::string dish_type;
public:
cuisine(string="",int=0);

void settypeName(string dish);

void setdishNum(int num);

std::string gettypeName();

int getdishNum();

};//class
#endif
30 changes: 30 additions & 0 deletions cuisineIm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>
#include <string>
#include"cuisine.h"
using namespace std;
cuisine::cuisine(string dish, int num)
{
std::string dish_type;
int num_of_dishes;
}
void cuisine::settypeName(std::string dish)
{

dish_type=dish;
}

void cuisine::setdishNum(int num)
{
num_of_dishes=num;
}

std::string cuisine::gettypeName()
{
return dish_type;
}

int cuisine::getdishNum()
{
return num_of_dishes;
}

63 changes: 63 additions & 0 deletions cuisinedriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include<iostream>
#include<string>
#include<vector>
#include "cuisine.h"
using namespace std;

int linearSearch(auto data, auto key);//prototype
int linearSearch(auto data, auto key)
{
for (int i=0; i<data.size(); i++)
{
if (data[i].getdishNum()==key)
{
return i;
}
}
return -1;
}


int main()
{
string dish;

int num;
int search_key;
vector<cuisine> restaurant;
cuisine order;

for(int i=0;i<4;i++)
{

cout << "Please enter the type of cuisine." << endl;

cin >> dish;

order.settypeName(dish);

cout << "Enter the number of dishes you have of this cuisine." <<endl;

cin >> num;

order.setdishNum(num);

restaurant.push_back(order);


}
cout <<" Enter an interger for a search key"<<endl;
cin >> search_key;

cout <<search_key <<" is in position: "<< linearSearch(restaurant,search_key);

/*for(int i=0;i<4;i++)
{
cout << restaurant[i].gettypeName() << ":" << restaurant[i].getdishNum() << endl;
}*/

return 0;

}