Jul 28, 2016 at 11:30am UTC  
 
Witam serdecznie :) 
 
Mam pracę dla Programisty C++ 
Miejsce: Kraków (Centrum) 
 
Praca stacjonarna, możliwość rozpoczęcia od zaraz 
 
Firma: start-up, który rozwija własne narzędzie - chmurę do przechowywania i zarządzania danymi.  
 
Wynagrodzenie: 5000 - 8000 PLN brutto (do negocjacji) 
 
Jeżeli chcesz rozpocząć pracę w firmie, która zapewni Ci samodzielną pracę z dostępem do najlepszego sprzętu, wachlarz benefitów oraz stabilne zatrudnienie - napisz do mnie ! :) 
 
w.fortowska@new-invest.pl
 
 
 
 
  Jul 28, 2016 at 2:28pm UTC  
 
Translate this into English please... 
 
Edit : You can press the "Edit" button and edit your main topic
Last edited on Jul 28, 2016 at 2:44pm UTC  
 
 
 
 
  Jul 30, 2016 at 5:00am UTC  
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 
#include <iostream> 
#include <fstream> 
#include <vector> 
#include <string> 
#include <ctime> 
#include <cstdlib> 
using  namespace  std;
class  trucks {
private  :
    int  ID;
    string Type;
    double  feeder_pt;
    double  axle_pt;
    int  num;
    double  entered_feeder_line;
    double  completed_feeder_line;
    double  entered_axle_hang;
    double  completed_axle_hang;
public :
    int  getID() {return  ID;}
    string getType() {return  Type;}
    double  getfeeder() {return  feeder_pt;}
    double  getaxle() {return  axle_pt;}
    double  getnum() {return  num;}
	double  getfeeder_entered() {return  entered_feeder_line;}
	double  getfeeder_completed() {return  completed_feeder_line;}
	double  getaxle_entered() {return  entered_axle_hang;}
	double  getaxle_completed() {return  completed_axle_hang;}
    void  setID (int  id) {ID = id;}
    void  setType (string type) {Type = type;}
    void  setfeeder (double  feeder) {feeder_pt = feeder;}
    void  setaxle (double  axle) {axle_pt = axle;}
    void  setnum (int  n) {num = n;}
	void  setfeeder_entered(double  feeder) {entered_feeder_line = feeder;}
	void  setfeeder_completed(double  feeder) {completed_feeder_line = feeder;}
	void  setaxle_entered(double  axle) {entered_axle_hang = axle;}
	void  setaxle_completed(double  axle) {completed_axle_hang = axle;}
};
int  main ()
{
	ifstream myfile("sequence.txt" );
	int  ID;
	string Type;
	double  feeder_pt;
	double  axle_pt;
	if (!myfile.is_open())
	cout << "Error : sequence.txt not found"  << endl;
	int  i;
	vector<trucks> truck;
	i = truck.size() - 1; if (i < 0) i = 0;
	while (myfile >> ID >> Type >> feeder_pt >> axle_pt)
	 {
		 truck.push_back(trucks());
		 truck[i].setID(ID);
		 truck[i].setType(Type);
		 truck[i].setfeeder(feeder_pt);
		 truck[i].setaxle(axle_pt);
		 truck[i].setaxle(axle_pt);
		 truck[i].setnum(i);
		 
		 i++;
	 }
	cout << "Print out all contents : "  << endl;
	for (i = 0; i < truck.size(); i++)
	{
		cout << truck[i].getID() << " " ;
		cout << truck[i].getType() << " " ;
		cout << truck[i].getfeeder() << " " ;
		cout << truck[i].getaxle() << endl;
	}
	cout << endl;
	cout << "Sequence Order Before : "  << endl;
	for (i = 0; i < truck.size(); i++) cout << truck[i].getnum() << " " ; cout << endl << endl;
	// This is where everything begins... 
	vector<trucks> truck_tmp;
	vector<int > truck_input;
	srand(time(NULL));
	truck_tmp.resize(truck.size());
	truck_input.resize(truck.size());
	/*
	bool bSuccess = false;
	while(bSuccess == false)
	{
		bSuccess = true;
		for(i = 0; i < truck.size(); i++)
		{
			truck_tmp[i] = truck[i];
			truck_input[i] = -1;
		}
		cout << "Please input the desired sequence order : ";
		for(i = 0; i < truck.size(); i++)
			cin >> truck_input[i];
		for(i = 0; i < truck.size(); i++)
			if(truck_input[i] < 0 || truck_input[i] >= truck.size())
			{
				cout << "You have entered the wrong sequence order. Please try again." << endl << endl;
				bSuccess = false; break;			
			}
		if(bSuccess == false) continue;
		for(i = 0; i < truck.size(); i++) truck_tmp[truck_input[i]].setType("C"); // "Closed"
		for(i = 0; i < truck.size(); i++)
			if(truck_tmp[i].getType() != "C")
			{
				cout << "You have entered the wrong sequence order. Please try again." << endl << endl;
				bSuccess = false; break;			
			}
		if(bSuccess == false) continue;
		for(i = 0; i < truck.size(); i++) truck_tmp[i] = truck[truck_input[i]];
		for(i = 0; i < truck.size(); i++) truck[i] = truck_tmp[i];
	}
	cout << endl;
	cout << "Sequence Order After : " << endl;
	for(i = 0; i < truck.size(); i++) cout << truck[i].getnum() << " "; cout << endl << endl;
	*/ 
	double  makespan = 0;
	double  feeder_line_A = 0;
	double  feeder_line_D = 0;
	double  axle_hang = 0;
	double  &axle_hang_A = axle_hang;
	double  &axle_hang_D = axle_hang;
	vector <trucks> axle_A;
	vector <trucks> axle_D;
	// This is a pointer 
	trucks *p_axle;
	for (i = 0; i < truck.size(); i++)
	{
		if (truck[i].getType() == "A" )
		{
			  truck[i].setfeeder_entered(feeder_line_A);
			  truck[i].setaxle_entered(axle_hang_A);
			  axle_hang_A = std::max(feeder_line_A, axle_hang_A);
			  axle_hang_A = std::max(axle_hang_A, feeder_line_A + truck[i].getfeeder());
			  axle_A.push_back(trucks());
			  axle_A.back().setaxle(axle_hang_A);
			  axle_hang_A += truck[i].getaxle();
			  if (axle_A.size() > 1)
			  {
				  p_axle = (trucks*) &axle_A[0] + (axle_A.size() - 2);
				   feeder_line_A = std::max(p_axle->getaxle(), feeder_line_A);
			  }
			 feeder_line_A += truck[i].getfeeder();
		
			  truck[i].setfeeder_completed(feeder_line_A);
			  truck[i].setaxle_completed(axle_hang_A);
		}
		else 
		{
			  truck[i].setfeeder_entered(feeder_line_D);
			  truck[i].setaxle_entered(axle_hang_D);
			  axle_hang_D = std::max(feeder_line_D, axle_hang_D);
			  axle_hang_D = std::max(axle_hang_D, feeder_line_D + truck[i].getfeeder());
			  axle_D.push_back(trucks());       
			  axle_D.back().setaxle(axle_hang_D);
			  axle_hang_D += truck[i].getaxle();
			  if (axle_D.size() > 1)
			  {
				   p_axle = (trucks*) &axle_D[0] + (axle_D.size() - 2);
				   feeder_line_D = std::max(p_axle->getaxle(), feeder_line_D);
			  }
			 feeder_line_D += truck[i].getfeeder();
			  truck[i].setfeeder_completed(feeder_line_D);
			  truck[i].setaxle_completed(axle_hang_D);
		}
	}
	cout << "Entered : "  << endl;
	for (i = 0; i < truck.size(); i++)
	{
	   cout << "feeder["  << i + 1 << "] ("  << truck[i].getType() << ") : "  << truck[i].getfeeder_entered() << endl;
	   cout << "axle["  << i + 1 << "] ("  << truck[i].getType() << ") : "  << truck[i].getaxle_entered() << endl;       
	}
	cout << endl;
	cout << "Completed : "  << endl;
	for (i = 0; i < truck.size(); i++)
	{
	   cout << "feeder["  << i + 1 << "] ("  << truck[i].getType() << ") : "  << truck[i].getfeeder_completed() << endl;
	   cout << "axle["  << i + 1 << "] ("  << truck[i].getType() << ") : "  << truck[i].getaxle_completed() << endl;       
	}
	makespan = axle_hang;
	cout << endl;
	cout << "makespan == "  << makespan << endl;
	return  0;
}
 
 
Last edited on Aug 6, 2016 at 2:12pm UTC  
 
 
 
 
  Jul 30, 2016 at 9:34am UTC  
 
@closed account.... 
 
What kind of code is this? Why does it look like Java all over? You do know C++ isn't JUST an OOP language like Java, right? The truck structure could have just been a POD. Small review: 
 
Remove all the annoying getters and setters, make the data fields public. 
Don't import all the names in the standard namespace, that's totally unacceptable. 
What is !file.is_open() ? Use the bool operator such that it makes it  if ( !file)  , then return immediately in your "if" conditional statement.  
Be consistent in your use of braces. E.g. Use braces around the statement for the conditional "if" statements. 
Overload operator>> so reading into the truck POD is simply or whatever. 
Use brace initializers to avoid confusing function calls with temporary objects. 
Where did you declare all the variables used in the code? 
 
 
 
God! I could go on and on about the code, but it wouldn't do much. Please clean this code up.
 
 
 
 
  Jul 30, 2016 at 10:44pm UTC  
 
@OxBADC0DE  
 
You know that closed account 5a8Ym39o6  is a troll right? 
 
And this is the jobs section? 
 
Messages have been sent to the site admin recently, and although things seemed to have calmed down a bit, the troll is back to the same old tricks .......
Last edited on Jul 31, 2016 at 12:15am UTC  
 
 
 
 
  Jul 30, 2016 at 11:22pm UTC  
 
@TheIdeasMan 
What are you doing...
 
 
 
 
  Jul 31, 2016 at 9:06am UTC  
 
@TheIdeasMan 
 
I didn't know. Thanks for the heads up.