الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

[مخالف - طلب حل : ]أرجو المساعدة في الRobot

مغلق
بدأه علي فايز الفايز في 27 أغسطس 2010 · 2 رد · 450 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

أهلاً أعزائي .. لو سمحتوا أريد الحل الكامل لهذا البرنامج ضروري وفي أسرع وقت ممكن .. ( أرجو مشاهدة المرفقات وتنفيذ المطلوب في ملف البي دي إف)

class RobotControl

{

private Robot r;

public RobotControl(Robot r)

{

this.r = r;

}

public void control(int barHeights[], int blockHeights[])

{

// Your implementation for controlling the arm in

// each "part" of the assignment should go in the

// corresponding method below.

// Make sure the call for latest version of the control

// method you have working is un-commented and that the

// calls for the other two versions of the control methods

// are commented out below.

// Also make sure you implementation for each subsequent

// "part" works for the scenario from the previous part(s).

controlPartA(barHeights, blockHeights);

//controlPartB(barHeights, blockHeights);

//controlPartC(barHeights, blockHeights);

}

public void controlPartA(int barHeights[], int blockHeights[])

{

//

// Internally the Robot object maintains the value for Robot height(h),

// arm-width (w) and picker-depth (d).

//

// These values are displayed for your convenience.

//

// These values are initialised as h=2 w=1 and d=0.

//

// When you call the methods up() or down() h will be changed.

//

// When you call the methods extend() or contract() w will be changed.

//

// When you call the methods lower() or raise() d will be changed.

//

// When you call speedUp(1) or slowDown(1) the robot will speed up

// or slow down by a factor of 1 (adjust this to your preference).

//

// Sample code to get you started follows below.

//

// Try running this program with no command line arguments

// (default case where obstacles are of heights 555555 and

// blocks are of height 123)

//

// It will work for fisrt block only

//

// You are free to introduce any other variables.

//

int armUp;

int armDown;

int armExtend;

int armContract;

int pickerDown;

int pickerUp;

//

// These variables might come in handy for parts B and C

//

//

int pickerHeight = 2;

int blockSize = 0;

//

// Hard coded values for the distance the

// arm needs to move in each direction.

//

// These values will need to change for the

// second and third blocks.

//

// You can remove these comments once you have an

// idea of how the robot works.

//

//

armUp = 9;

armExtend = 9;

pickerDown = 4;

pickerUp = 4;

armContract = 7;

armDown = 7;

for (int i = 1; i <= armUp; i++)

{

r.up();

}

for (int i = 1; i <= armExtend; i++)

{

r.extend();

}

for (int i = 1; i <= pickerDown; i++)

{

r.lower();

}

r.pick();

for (int i = 1; i <= pickerUp; i++)

{

r.raise();

}

for (int i = 1; i <= armContract; i++)

{

r.contract();

}

for (int i = 1; i <= armDown; i++)

{

r.down();

}

r.drop();

//

// Think about what needs to change for the next block -

// take note of the position of the arm when working out

// how far the arm need to move in each direction when

// the other two blocks.

//

//

}

public void controlPartB(int [] barHeights, int [] blockHeights)

{

// add in any other variables you need

int pickerHeight = 2;

int blockSize = 0;

// for this part of the assignment you MUST use

// loops so that the code for moving one block

// is executed three times so that all of the

// blocks can be moved from the source to their

// respective target piles.

// eg.

//

// for (int i = 1; i < 3; i++)

// {

//

// for (int j = 1; j <= armUp; i++)

// {

// r.up();

// }

//

// for (int j = 1; j <= armUp; i++)

// {

// r.up();

// }

//

// etc.

// }

// Your robot must also take the heights of the obstacles

// into account when determining how high the arm needs to be

// moved up - moving the arm to it's maximum height by default

// is not an acceptable solution.

}

public void controlPartC(int [] barHeights, int [] blockHeights)

{

int pickerHeight = 2;

int blockSize = 0;

// For this part of the assignment you MUST use

// loops so that the code for moving one block

// is executed as many times as is needed so that

// all of the blocks can be moved from the source

// to their respective target piles.

//

// The length of the blockHeights array will tell

// you how many blocks need to be moved.

// eg.

//

// for (int i = 1; i < __________ ; i++)

// {

//

// for (int j = 1; j <= armUp; i++)

// {

// r.up();

// }

//

// for (int j = 1; j <= armUp; i++)

// {

// r.up();

// }

//

// etc.

// }

}

}

كما ترون فإن المطلوب من السؤال قد وضع داخل البرنامج وشكراً

RobotControl.java

تم تعديل هذه المشاركة بواسطة علي فايز الفايز في 27 أغسطس 2010 في 07:23

#2

عفواً فقد نسيت إرفاق ملف البي دي إف ..

the Questions.pdf

#3

الأخ الكريم/الأخت الكريمة

السلام عليكم ورحمة الله وبركاته.

مرحباً بكم في منتدى الفريق العربي للبرمجة

تأسف إدارة المنتدى لغلق الموضوع وذلك لمخالفته قوانين المشاركات، فقرة طلب حل الواجبات والتمارين.

قواعد طرح المشاركات

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

هذا الموضوع مغلق.

مواضيع مشابهة